Hướng dẫn show table mysql - hiển thị bảng mysql

Mô tả có nghĩa là hiển thị thông tin chi tiết. Vì chúng tôi có các bảng trong MySQL, vì vậy chúng tôi sẽ sử dụng lệnh mô tả để hiển thị cấu trúc của bảng của chúng tôi, chẳng hạn như tên cột, các ràng buộc trên tên cột, v.v ... Lệnh DSC là một dạng ngắn của lệnh mô tả. Cả hai lệnh mô tả và DESC đều tương đương và nhạy cảm trường hợp.DESCRIBE command to show the structure of our table, such as column names, constraints on column names, etc. The DESC command is a short form of the DESCRIBE command. Both DESCRIBE and DESC command are equivalent and case sensitive.DESCRIBE command to show the structure of our table, such as column names, constraints on column names, etc. The DESC command is a short form of the DESCRIBE command. Both DESCRIBE and DESC command are equivalent and case sensitive.

Nội dung chính ShowShow

  • Đăng nhập vào cơ sở dữ liệu MySQL
  • Chuyển sang cơ sở dữ liệu cụ thể
  • Thực thi câu lệnh mô tả
  • Làm thế nào để hiển thị thông tin bảng trong MySQL Workbench?
  • Lệnh mysql show cột
  • MySQL giải thích
  • Làm thế nào tôi có thể thấy cấu trúc của một bảng trong mysql?
  • Làm thế nào để bạn hiển thị cấu trúc của một bảng?
  • Làm cách nào để thấy các cấu trúc bảng trong MySQL Workbench?
  • Lệnh DSC trong MySQL là gì?

Cú pháp

Sau đây là cú pháp để hiển thị cấu trúc bảng:

Chúng ta có thể sử dụng các bước sau để hiển thị tất cả các cột của bảng:::

Bước 1: Đăng nhập vào máy chủ cơ sở dữ liệu MySQL. Login into the MySQL database server. Login into the MySQL database server.

Bước 2: Chuyển sang cơ sở dữ liệu cụ thể. Switch to a specific database. Switch to a specific database.

Bước 3: Thực hiện câu lệnh mô tả. Execute the DESCRIBE statement. Execute the DESCRIBE statement.

Hãy cho chúng tôi hiểu nó với sự trợ giúp của một ví dụ giải thích cách hiển thị các cột của bảng trong cơ sở dữ liệu đã chọn.

Đăng nhập vào cơ sở dữ liệu MySQL

Chuyển sang cơ sở dữ liệu cụ thểusername and password. We should see the output as below image:

Hướng dẫn show table mysql - hiển thị bảng mysql

Chuyển sang cơ sở dữ liệu cụ thể

Thực thi câu lệnh mô tả

Thực thi câu lệnh mô tả

Làm thế nào để hiển thị thông tin bảng trong MySQL Workbench?SHOW TABLES statement:

Lệnh mysql show cột, if we want to show a customer table's structure, execute the below statement. After successful execution, it will give the output as below image:

MySQL giải thích

Làm thế nào để hiển thị thông tin bảng trong MySQL Workbench?

Lệnh mysql show cột

MySQL giải thích

Làm thế nào tôi có thể thấy cấu trúc của một bảng trong mysql?Navigation tab and click on the Schema menu. Here, we can see all the previously created databases. Select any database under the Schema menu, for example, mysqltestdb. It will pop up the multiple options that can be shown in the following image.

Làm thế nào để bạn hiển thị cấu trúc của một bảng?Tables" that shows all tables stored in the mysqltestdb database. Select a table whose column information you want to display. Then, mouse hour on that table, it will show three icons. See the below image:

Làm cách nào để thấy các cấu trúc bảng trong MySQL Workbench? icon (i) shown in the red rectangular box. It will display the following image:

Lệnh DSC trong MySQL là gì?Columns" menu to display the table structure.

Lệnh mysql show cột

MySQL giải thích

Syntax:

Làm thế nào tôi có thể thấy cấu trúc của một bảng trong mysql?

Làm thế nào để bạn hiển thị cấu trúc của một bảng?, if we execute the below query, we will get all columns information of a table in a particular database:

Nếu chúng tôi muốn hiển thị thông tin cột của bảng từ cơ sở dữ liệu khác hoặc không có sẵn trong cơ sở dữ liệu hiện tại, chúng tôi có thể sử dụng truy vấn sau:columns information of a table from another database or not available in the current database, we can use the following query:columns information of a table from another database or not available in the current database, we can use the following query:

Trong hình ảnh dưới đây, chúng ta có thể thấy rằng chúng ta đã sử dụng cơ sở dữ liệu MySQLTestDB. Nhưng chúng tôi đã hiển thị thông tin của một bảng từ cơ sở dữ liệu khác mà không chuyển sang cơ sở dữ liệu hiện tại.

Nếu chúng tôi muốn hiển thị thêm thông tin cột, chúng tôi cần thêm từ khóa đầy đủ với câu lệnh Hiển thị bảng như sau:FULL keyword with the SHOW TABLES statement as follows:FULL keyword with the SHOW TABLES statement as follows:

Ví dụ: truy vấn SQL dưới đây liệt kê tất cả các cột của bảng student_info trong cơ sở dữ liệu MystudentDB:, the below SQL query lists all columns of the student_info table in the mystudentdb database:, the below SQL query lists all columns of the student_info table in the mystudentdb database:

Sau khi thực hiện, chúng ta có thể thấy rằng lệnh này thêm các cột đối chiếu, đặc quyền, mặc định và nhận xét vào tập kết quả.collation, privileges, default, and comment columns to the result set.collation, privileges, default, and comment columns to the result set.

MySQL giải thích

Từ khóa giải thích là từ đồng nghĩa với câu lệnh mô tả, được sử dụng để có được thông tin về cách MySQL thực thi các truy vấn. Nó có thể hoạt động với chèn, chọn, xóa, cập nhật và thay thế các truy vấn. Từ các phiên bản MySQL 8.0.19 trở lên, nó cũng có thể hoạt động với các câu lệnh bảng. Khi chúng tôi sử dụng từ khóa này trong các truy vấn, nó sẽ xử lý câu lệnh và cung cấp thông tin về cách tham gia các bảng, thứ tự của bảng, các phân vùng ước tính và hàng.used to obtain information about how MySQL executes the queries. It can work with INSERT, SELECT, DELETE, UPDATE, and REPLACE queries. From MySQL 8.0.19 and later versions, it can also work with TABLE statements. When we use this keyword in queries, it will process the statement and provide the information about how tables are joined, the order of the table, estimated partitions and rows.used to obtain information about how MySQL executes the queries. It can work with INSERT, SELECT, DELETE, UPDATE, and REPLACE queries. From MySQL 8.0.19 and later versions, it can also work with TABLE statements. When we use this keyword in queries, it will process the statement and provide the information about how tables are joined, the order of the table, estimated partitions and rows.

Thí dụ

Nếu chúng tôi muốn hiển thị kế hoạch thực thi của một câu lệnh select, chúng tôi có thể sử dụng truy vấn như dưới đây:SELECT statement, we can use the query as below:SELECT statement, we can use the query as below:

Output:

Truy vấn này tạo ra các thông tin sau:


Làm thế nào tôi có thể thấy cấu trúc của một bảng trong mysql?

MySQL cũng cho phép lệnh các cột hiển thị cấu trúc bảng. Đó là một cách linh hoạt hơn để lấy thông tin cột của bảng ....

mysql> hiển thị các cột từ cơ sở dữ liệu_name. Table_Name ;.

mysql> hiển thị các cột từ TABLE_NAME trong cơ sở dữ liệu_name ;.

Làm thế nào để bạn hiển thị cấu trúc của một bảng?

Vì vậy, lệnh desc hoặc mô tả cho thấy cấu trúc của bảng bao gồm tên của cột, loại dữ liệu của cột và khả năng vô hiệu có nghĩa là, cột đó có thể chứa các giá trị null hoặc không.desc or describe command shows the structure of table which include name of the column, data-type of column and the nullability which means, that column can contain null values or not.desc or describe command shows the structure of table which include name of the column, data-type of column and the nullability which means, that column can contain null values or not.

Làm cách nào để thấy các cấu trúc bảng trong MySQL Workbench?

Để mở, nhấp chuột phải vào một bảng trong trình duyệt đối tượng của khung Navigator và chọn Trình kiểm tra bảng từ menu ngữ cảnh.Thanh tra bảng hiển thị thông tin liên quan đến bảng.right-click a table in the object browser of the Navigator pane and choose Table Inspector from the context menu. The Table Inspector shows information related to the table.right-click a table in the object browser of the Navigator pane and choose Table Inspector from the context menu. The Table Inspector shows information related to the table.

Lệnh DSC trong MySQL là gì?

DESC là dạng ngắn của lệnh mô tả và được sử dụng để giảm thông tin về một bảng như tên cột và các ràng buộc trên tên cột.Lệnh mô tả tương đương với lệnh sau - hiển thị các cột từ lệnh của bạn.the short form of DESCRIBE command and used to dipslay the information about a table like column names and constraints on column name. The DESCRIBE command is equivalent to the following command − SHOW columns from yourTableName command.the short form of DESCRIBE command and used to dipslay the information about a table like column names and constraints on column name. The DESCRIBE command is equivalent to the following command − SHOW columns from yourTableName command.