首页 >数据库 >mysql教程 >mysql查看表结构和表创建语命令_MySQL

mysql查看表结构和表创建语命令_MySQL

WBOY
WBOY原创
2016-06-01 13:02:371015浏览

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 set
2、显示创建表表名; 
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 set
3、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 行

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn