show COLUMNS from 表名 /*查看字段*/
mysql> show columns from user_login;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| sessionId | bigint(255) | YES | | 0 | |
| user_id | varchar(32) | YES | MUL | NULL | |
| srctype | tinyint(4) | YES | | NULL | |
| ip | varchar(64) | YES | | NULL | |
| login_time | datetime | YES | | NULL | |
+------------+-------------+------+-----+---------+----------------+
show full fieds from 表名
show full COLUMNS from 表名 /*查看字段详情,包括comment*/
full fields 和 full columns效果一样:
mysql> show full COLUMNS from user_login;
+------------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------------------------------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+------------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------------------------------+
| id | int(11) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | id |
| sessionId | bigint(255) | NULL | YES | | 0 | | select,insert,update,references | 一次会话ID |
| user_id | varchar(32) | utf8_general_ci | YES | MUL | NULL | | select,insert,update,references | |
| srctype | tinyint(4) | NULL | YES | | NULL | | select,insert,update,references | 用户登录设备,0:mds,1:gqs |
| ip | varchar(64) | utf8_general_ci | YES | | NULL | | select,insert,update,references | 用户IP |
| login_time | datetime | NULL | YES | | NULL | | select,insert,update,references | 用户最近登录时间 |
+------------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------------------------------+
6 rows in set (0.00 sec)
mysql> show full fields from user_login;
+------------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------------------------------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+------------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------------------------------+
| id | int(11) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | id |
| sessionId | bigint(255) | NULL | YES | | 0 | | select,insert,update,references | 一次会话ID |
| user_id | varchar(32) | utf8_general_ci | YES | MUL | NULL | | select,insert,update,references | |
| srctype | tinyint(4) | NULL | YES | | NULL | | select,insert,update,references | 用户登录设备,0:mds,1:gqs |
| ip | varchar(64) | utf8_general_ci | YES | | NULL | | select,insert,update,references | 用户IP |
| login_time | datetime | NULL | YES | | NULL | | select,insert,update,references | 用户最近登录时间 |
+------------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------------------------------+
show create table 表名; /*查看创建语句*/
mysql> show create table func;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| func | CREATE TABLE `func` (
`name` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`ret` tinyint(1) NOT NULL DEFAULT '0',
`dl` char(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`type` enum('function','aggregate') CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions' |