MySQL view table structure and table creation commands

Source: Internet
Author: User

1, desc TableName;

Mysql> desc authors;+-------+--------------+------+-----+---------+----------------+| Field | Type         | Null | Key | Default | Extra          |+-------+--------------+------+-----+---------+----------------+| ID    | int      | NO   | PRI | NULL    | auto_increment | | email | varchar (100) | NO   | UNI | NULL    |                | | name  | varchar (100) | NO   |     | NULL    |                | +-------+--------------+------+-----+---------+----------------+3 rows in Set

2,ShowCreate TableTableName;

Mysql> Show CREATE TABLE authors;+---------+------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ------------------------------------------------------+| Table |                                                                                                                                                                                                                           Create Table |+---------+- --------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ---------+| Authors | CREATE TABLE ' authors ' (' id ' int (one) not null auto_increment, ' email ' varchar (+) NOT null, ' name ' varchar (+) ' N ' ULL, PRIMARY key (' id '), UNIQUE key ' email ' (' email ')) Engine=innodb auto_increment=2 DEFAULT CHArset=utf8 |+---------+---------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- ---------------------------------+1 Row in Set

3,select * from columns where table_name= ' table name '


mysql> use INFORMATION_SCHEMA;
Database changed
Mysql> SELECT * from columns where table_name= ' authors ';
+---------------+--------------+------------+-------------+------------------+----------------+-------------+-- ---------+--------------------------+------------------------+-------------------+---------------+------------- -------+-----------------+--------------+------------+----------------+---------------------------------+------ ----------+
| Table_catalog | Table_schema | table_name | column_name | ordinal_position | Column_default | is_nullable | Data_type | Character_maximum_length | Character_octet_length | numeric_precision | Numeric_scale | Character_set_name | Collation_name | Column_type | Column_key | EXTRA | privileges | column_comment |
+---------------+--------------+------------+-------------+------------------+----------------+-------------+-- ---------+--------------------------+------------------------+-------------------+---------------+------------- -------+-----------------+--------------+------------+----------------+---------------------------------+------ ----------+
| def | Zqad | Authors |                ID | 1 | NULL | NO | int | NULL |                NULL |             10 | 0 | NULL | NULL | Int (11) | PRI | auto_increment |                select,insert,update,references | |
| def | Zqad | Authors |                email | 2 | NULL | NO |                      varchar |                    100 | 300 | NULL | NULL | UTF8 | Utf8_general_ci | varchar (100) |                UNI | |                select,insert,update,references | |
| def | Zqad | Authors |                name | 3 | NULL | NO |                      varchar |                    100 | 300 | NULL | NULL | UTF8 | Utf8_general_ci |            varchar (100) |                | |                select,insert,update,references | |
+---------------+--------------+------------+-------------+------------------+----------------+-------------+-- ---------+--------------------------+------------------------+-------------------+---------------+------------- -------+-----------------+--------------+------------+----------------+---------------------------------+------ ----------+
3 Rows in Set

MySQL view table structure and table creation 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.