摘要:

下文讲述MySQL数据库中查看表结构的三种方法分享,如下所示;

实现思路:

方式1:desc 数据表名称

方式2:show columns from 数据表名称

方式3:show create table 数据表名称

例:

查看”maomao365.comC”表的表结构的示例分享

mysq> desc `maomao365.comC`;

+-------+--------------------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+--------------------------+------+-----+---------+-------+

| keyId | int(2) unsigned zerofill | YES | | NULL | |

+-------+--------------------------+------+-----+---------+-------+

1 row in set (0.00 sec)

mysql> show columns from `maomao365.comC`;

+-------+--------------------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------+--------------------------+------+-----+---------+-------+

| keyId | int(2) unsigned zerofill | YES | | NULL | |

+-------+--------------------------+------+-----+---------+-------+

1 row in set (0.00 sec)

mysql> show create table `maomao365.comC`;

+----------------+------------------------------------------------------------------------------------------------------------------------+

| Table | Create Table |

+----------------+------------------------------------------------------------------------------------------------------------------------+

| maomao365.comC | CREATE TABLE `maomao365.comC` (

`keyId` int(2) unsigned zerofill DEFAULT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1 |

+----------------+------------------------------------------------------------------------------------------------------------------------+

1 row in set (0.00 sec)