MySQL查看表结构及建表语句

  • MySQL查看表结构:desc tablename;
mysql> desc weijing;
+--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| Id     | int(11)     | NO   | PRI | NULL    | auto_increment |
| Name   | varchar(20) | YES  |     | NULL    |                |
| Date   | date        | YES  |     | NULL    |                |
| Scount | int(11)     | YES  |     | NULL    |                |
+--------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

 

  • MySQL查看建表语句:show create table tablename;
mysql> show create table weijing;
+---------+------------------------------------------------------------------+
| Table   | Create Table                                                                                                                                                                                                                                |
+---------+------------------------------------------------------------------+
| weijing | CREATE TABLE `weijing` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(20) DEFAULT NULL,
  `Date` date DEFAULT NULL,
  `Scount` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 |
+---------+------------------------------------------------------------------+
1 row in set (0.01 sec)

发表评论