View mysql table structure information

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.