1,desc 表名;
mysql> desc authors; +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | email | varchar(100) | NO | UNI | NULL | | | name | varchar(100) | NO | | NULL | | +-------+--------------+------+-----+---------+----------------+ 3 rows in set2、显示创建表表名;
mysql> show create table authors; +---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | authors | CREATE TABLE `authors` ( `id` int(11) NOT NULL AUTO_INCREMENT, `email` varchar(100) NOT NULL, `name` varchar(100) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 | +---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set3、select * from columns where table_name='表名'
mysql>使用信息模式;
数据库已更改
mysql>从 table_name='authors';
的列中选择 *
--------------- -------------- ------------ --------- ---- ------------------ ---------------- ------------------------ - ----------- -------------------------- ------------ ------------ -------------------------------- --------------- ---- ---------------- ----------------- -------------- --- --------- ---------------- ------------------------- -------------------- ----------------
|表目录|表模式 |表名 | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT | 列IS_NULLABLE | IS_NULLABLE |数据类型 | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH |数值精度 | NUMERIC_SCALE | CHARACTER_SET_NAME | COLLATION_NAME | COLUMN_TYPE | 列类型COLUMN_KEY |额外|特权 | COLUMN_COMMENT |
--------------- -------------- ------------ --------- ---- ------------------ ---------------- ------------------------ - ----------- -------------------------- ------------ ------------ -------------------------------- --------------- ---- ---------------- ----------------- -------------- --- --------- ---------------- ------------------------- -------------------- ----------------
|定义 |兹卡德 |作者 |编号 | 1 |空|否 |整数 |空|空| 10 | 10 0 |空|空|整数(11)|优先原则 |自动增量 |选择、插入、更新、引用 | |
|定义 |兹卡德 |作者 |电子邮件 | 2 |空|否 | varchar | 100 | 100 300 | 300空|空| UTF8 | utf8_general_ci | utf8_general_ci | varchar(100) | varchar(100) |大学| |选择、插入、更新、引用 | |
|定义 |兹卡德 |作者 |名称 | 3 |空|否 | varchar | 100 | 100 300 | 300空|空| UTF8 | utf8_general_ci | utf8_general_ci | varchar(100) | varchar(100) | | |选择、插入、更新、引用 | |
--------------- -------------- ------------ --------- ---- ------------------ ---------------- ------------------------ - ----------- -------------------------- ------------ ------------ -------------------------------- --------------- ---- ---------------- ----------------- -------------- --- --------- ---------------- ------------------------- -------------------- ----------------
一组 3 行