1. A simple description of the table structure. The field type is desctabl_name; or describecolumns. The table structure, field type, primary key, whether it is empty, and other attributes are displayed, but the comments of Foreign keys and fields are not displayed. 2. View The Name Of The DDLshowcreatetable table generated by the table. Although this command is not easy to see, it is not a problem and can be used.
1. A simple description of the table structure. The field type is desc tabl_name; or describe columns. The table structure, field type, primary key, whether it is empty, and other attributes are displayed, but the comments of Foreign keys and fields are not displayed. 2. view the name of the DDL show create table generated by the table. Although this command is not easy to see, it is not a problem and can be used.
1. Simple Description of table structure and Field Type
Desc tabl_name; or describe columns;
Displays the table structure, field type, primary key, whether it is empty, and other attributes, but does not display comments of Foreign keys and fields.
Ii. view the DDL generated by the table
Show create table name;
Although this command is not easy to see, it is not a problem that can end with \ G to make the results easy to read. This command displays the DDL of the table to be created, so the table structure and type are as follows, the foreign key and remarks are all displayed. I prefer this command: the input is simple and the display result is comprehensive.
Iii. query the comment information of columns in the table
Use information_schema
Select * from columns where table_name = 'table name ';
4. View table comments
Select table_name, table_comment frominformation_schema.tables where table_schema = 'db' and table_name = 'table name'
5. Only query column names and comments
Select column_name, column_comment from information_schema.columnswhere table_schema = 'db' and table_name = 'table name ';
Original article address: view the mysql table structure information. Thank you for sharing it with the original author.