SHOW COLUMNS FROM 数据表:显示数据表的属性,属性类型,主键信息,是否为NULL,默认值等其他信息。
1
2
3
4
5
6
7
8
9
10
|
mysql> SHOW COLUMNS FROM runoob_tbl; +-----------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+-------+ | runoob_id | int ( 11 ) | NO | PRI | NULL | |
| runoob_title | varchar( 255 ) | YES | | NULL | |
| runoob_author | varchar( 255 ) | YES | | NULL | |
| submission_date | date | YES | | NULL | | +-----------------+--------------+------+-----+---------+-------+ 4 rows in set ( 0.01 sec)
|
SHOW INDEX FROM 数据表:显示数据表的详细索引信息,包括PRIMARY KEY(主键)。
1
2
3
4
5
6
7
|
mysql> SHOW INDEX FROM runoob_tbl; +------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | runoob_tbl | 0 | PRIMARY | 1 | runoob_id | A | 2 | NULL | NULL | | BTREE | | |
+------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 1 row in set ( 0.00 sec)
|
SHOW TABLE STATUS LIKE [FROM db_name] [LIKE 'pattern'] \G:该命令输出MySQL数据库管理系统的性能以及统计信息。
1
2
3
4
|
mysql> SHOW TABLE STATUS FROM RUNOOB; # 显示数据库 RUNOOB 中所有表的信息 mysql> SHOW TABLE STATUS from RUNOOB LIKE 'runoob%' ; # 表名以runoob开头的表的信息
mysql> SHOW TABLE STATUS from RUNOOB LIKE 'runoob%' \G; # 加上 \G,查询结果按列打印
|
本文转自lq201151CTO博客,原文链接: http://blog.51cto.com/liuqun/2044071,如需转载请自行联系原作者