1,查看基本表结构: DESCRIBE(DESC) 表名;
eg: desc t_book;
结果:
mysql> desc t_book;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| bookName | varchar(20) | YES | | NULL | |
| author | varchar(10) | YES | | NULL | |
| price | decimal(6,2) | YES | | NULL | |
| bookTypeId | int(11) | YES | MUL | NULL | |
+------------+--------------+------+-----+---------+----------------+
5 rows in set (0.07 sec)
2,查看表详细结构: SHOW CREATE TABLE 表名;(写出创建表时的语句)
eg show create table t_book;
结果:
| Table | Create Table
| t_book | CREATE TABLE `t_book` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bookName` varchar(20) DEFAULT NULL,
`author` varchar(10) DEFAULT NULL,
`price` decimal(6,2) DEFAULT NULL,
`bookTypeId` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk` (`bookTypeId`),
CONSTRAINT `fk` FOREIGN KEY (`bookTypeId`) REFERENCES `t_booktype` (`id`)