MySQL view table structure simple commands.

Source: Internet
Author: User

I. Simple description table structure, field type

Desc Tabl_name;

Displays the table structure, the field type, the primary key, whether it is empty, and so on, but does not display foreign keys.

Second, the query table column of the comment information

SELECT * FROM Information_schema.columns

where Table_schema = ' db ' #表所在数据库

and table_name = ' tablename '; #你要查的表

Querying column names and comments only

Select column_name, column_comment from information_schema.columns where table_schema = ' db ' and table_name = ' tablename ' ;

Iv. #查看表的注释

Select Table_name,table_comment from information_schema.tables where table_schema = ' db ' and table_name = ' tablename '

PS: two ~ Four is in the metadata table to view, I in the actual operation, often do not have the light, do not know why, have the understanding of the heroes please leave the printing.

V. View the DDL generated by the table

Show CREATE TABLE table_name;

Although this command is not very easy to see, this is not a problem can be \g to the end, making the results easy to read; The command displays the DDL that created the table, so the table structure, type, foreign key, and comments are all displayed. I prefer this command: the input is simple and the results are comprehensive.

MySQL view table structure simple commands.

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.