mysql 表的定义和字段的查看

来源:互联网 发布:光猫 连接端口 编辑:程序博客网 时间:2024/05/21 10:30

desc 表名

查看表的信息

mysql> desc city;+-------------+----------+------+-----+---------+----------------+| Field       | Type     | Null | Key | Default | Extra          |+-------------+----------+------+-----+---------+----------------+| ID          | int(11)  | NO   | PRI | NULL    | auto_increment || Name        | char(35) | NO   |     |         |                || CountryCode | char(3)  | NO   | MUL |         |                || District    | char(20) | NO   |     |         |                || Population  | int(11)  | NO   |     | 0       |                |+-------------+----------+------+-----+---------+----------------+5 rows in set

表定义的查看

show create table 表名;

mysql> show create table city;| Table | Create Table| city  | CREATE TABLE `city` (  `ID` int(11) NOT NULL AUTO_INCREMENT,  `Name` char(35) NOT NULL DEFAULT '',  `CountryCode` char(3) NOT NULL DEFAULT '',  `District` char(20) NOT NULL DEFAULT '',  `Population` int(11) NOT NULL DEFAULT '0',  PRIMARY KEY (`ID`),  KEY `CountryCode` (`CountryCode`),  CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `country` (`Code`)) ENGINE=InnoDB AUTO_INCREMENT=4080 DEFAULT CHARSET=latin1 1 row in set
0 0
原创粉丝点击