天天看点

comment desc显示表结构_【数据库】】MySQL之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 :其它信息

原文:http://www.cnblogs.com/yanglang/p/7603115.html