【數據庫】】MySQL之desc查看表結構的詳細信息
阿新 • • 發佈:2017-09-27
類型 dex des varchar 其它 定義 creat eat desc
在mysql中如果想要查看表的定義的話;有如下方式可供選擇
1、show create table 語句:
show create table table_name;
2、desc table_name 語句:
create table person( id int not null auto_increment primary key, name varchar(8), index ix__person__name (name)); desc person; +-------+------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(8) | YES | MUL | NULL | | +-------+------------+------+-----+---------+----------------+
由這個例子可以看出:
Field:字段表示的是列名
Type:字段表示的是列的數據類型
Null :字段表示這個列是否能取空值
Key :在mysql中key 和index 是一樣的意思,這個Key列可能會看到有如下的值:PRI(主鍵)、MUL(普通的b-tree索引)、UNI(唯一索引)
Default: 列的默認值
Extra :其它信息
【數據庫】】MySQL之desc查看表結構的詳細信息