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