语法
查看当前数据库所有的表show tables;
查看表的基本信息show create table 表名;
查看表的字段信息desc 表名;
例子
查看当前数据库所有的表
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| tb3 |
+----------------+
1 row in set (0.09 sec)
查看表的基本信息
mysql> show create table tb3;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tb3 | CREATE TABLE `tb3` (`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,`username` varchar(20) NOT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.24 sec)
查看表的字段信息
mysql> desc tb3;
+----------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------------------+------+-----+---------+----------------+
| id | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| username | varchar(20) | NO | | NULL | |
+----------+----------------------+------+-----+---------+----------------+
2 rows in set (0.15 sec)