View MySQL table structure

Source: Internet
Author: User

Foreword: Recently in the internship, to do with the MySQL related development, think of a long time ago a pen test--to see the database table structure of what kinds of methods;

(i) using the describe statement


Or
DESC table_name;

The latter is the shorthand form of the former. This method is the simplest statement.

(ii) SHOW columns statement

 from table_name;

The effect is the same as above.

(iii) SHOW CREATE statement

CREATE TABLE table_name;

This statement differs from the above in that it is used primarily to display MySQL statements that create a particular table (which can also be used to display SQL statements created by the database).

(iv) Querying from the INFORMATION_SCHEMA database

SELECT *  from information_schema. COLUMNSWHERE='table_name'\g   

This statement can view the details of the table.

From the official MySQL documentation, you can tell: Information_schema is a standalone database that holds instance data for all other databases, that is, metadata for other databases, including database names, table names, column names, and so on. Of course Information_shema is a read-only database.

Using the above statement, you can switch to the INFORMATION_SCHEMA database using use, or you can directly access the corresponding table information in the form of "database name _ table name" above.

View MySQL table structure

Related Article

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.