我比较喜欢这个命令:输入简单,显示结果全面。
MySQL查看表结构简单命令。一、简单描述表结构,字段类型desctabl_name显示表结构,字段类型,主键,是否为空等属性,但不显示外键。二、查询表中列的注释信息select*frominformation_schema.columnswheretable_schema='db'#表所在数据库andtable_name='tablename'#你要查的表三、只查询列名和注释selectcolumn_name,column_commentfrominformation_schema.columnswheretable_schema='db'andtable_name='tablename'四、#查看表的注释selecttable_name,table_commentfrominformation_schema.tableswheretable_schema='db'andtable_name='tablename'ps:二~四是在元数据表中查看,我在实际 *** 作中,常常不灵光,不知为什么,有了解的大侠请留印。五、查看表生成的DDLshowcreatetabletable_name这个是查看表结构mysql> desc mtb_zip
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| zip_id | int(11) | NO | PRI | 0 | |
| zipcode | text | YES | | NULL | |
| state | text | YES | | NULL | |
| city | text | YES | | NULL | |
| town | text | YES | | NULL | |
+---------+---------+------+-----+---------+-------+
5 rows in set (0.03 sec)
这个是查看建表语句的
mysql> show create table mtb_zip
+---------+-----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----+
| Table | Create Table
|
+---------+-----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----+
| mtb_zip | CREATE TABLE `mtb_zip` (
`zip_id` int(11) NOT NULL DEFAULT '0',
`zipcode` text,
`state` text,
`city` text,
`town` text,
PRIMARY KEY (`zip_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+---------+-----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----+
1 row in set (0.00 sec)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)