mysql 查看表结构的指令

  1. desc tablenamename;
  2. describe tablename;
  3. show columns tablename;
  4. show create table tablename;

1,2,3展示的是

+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| id          | int(11)     | NO   | PRI | NULL    | auto_increment |
| uid         | int(11)     | NO   |     | 0       |                |
| create_time | int(11)     | NO   |     | NULL    |                |
| grade       | varchar(10) | YES  |     | NULL    |                |
+-------------+-------------+------+-----+---------+----------------+

第4中是把创建表的语句打出来,如下;

+--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t_test | CREATE TABLE `t_test` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘ID‘,
  `uid` int(11) NOT NULL DEFAULT ‘0‘ COMMENT ‘用户id‘,
  `create_time` int(11) NOT NULL COMMENT ‘发放时间‘,
  `grade` varchar(10) DEFAULT NULL COMMENT ‘等级‘,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8               |

时间: 2024-08-02 23:02:21

mysql 查看表结构的指令的相关文章

mysql查看表结构命令

mysql查看表结构命令,如下: desc 表名;show columns from 表名;describe 表名;show create table 表名; use information_schemaselect * from columns where table_name='表名'; 顺便记下:show databases;use 数据库名;show tables; 原有一unique索引AK_PAS_Name(PAC_Name)在表tb_webparamcounter中,执行以下sql

MySQL 查看表结构

mysql查看表结构命令,如下: desc 表名; show columns from 表名; describe 表名; show create table 表名; use information_schema select * from columns where table_name='表名'; 顺便记下: show databases; use 数据库名; show tables; 原有一unique索引AK_PAS_Name(PAC_Name)在表tb_webparamcounter中,

mysql查看表结构2种方式对比

1.desc t_bookType; 2.show create table t_bookType; 相信大部分人还是喜欢第一种查看表结构方式.

mysql查看表结构方法整理

在Mysql的shell命令行下查询表的结构: 1.desc(描述)命令 desc tablename; describe tablename; 2.show命令 show columns from tablename; show create table tablename 3.select命令(SQL语句) #查看表中所有列的信息 use information_schema; select column_name from columns where table_name='table_n

MySQL 查看表结构简单命令。

一.简单描述表结构,字段类型 desc tabl_name; 显示表结构,字段类型,主键,是否为空等属性,但不显示外键. 二.查询表中列的注释信息 select * from information_schema.columns where table_schema = 'db'  #表所在数据库 and table_name = 'tablename' ; #你要查的表 三.只查询列名和注释 select  column_name, column_comment from informatio

MySQL 查看表结构简单命令

一.简单描述表结构,字段类型 desc tabl_name; 显示表结构,字段类型,主键,是否为空等属性,但不显示外键. 例如:desc table_name 二.查询表中列的注释信息 select * from information_schema.columns where table_schema = 'db' #表所在数据库 and table_name = 'tablename' ; #你要查的表 例如: 可以自动选择你需要信息 三.只查询列名和注释 select column_nam

【MySQL】MySQL 查看表结构简单命令

一.简单描述表结构,字段类型 desc tabl_name; 显示表结构,字段类型,主键,是否为空等属性,但不显示外键. 例如:desc table_name 二.查询表中列的注释信息 select * from information_schema.columnswhere table_schema = 'db' #表所在数据库and table_name = 'tablename' ; #你要查的表 例如: 可以自动选择你需要信息 三.只查询列名和注释select column_name,

mysql查看表结构和表创建语命令

1,desc tablename; mysql> desc authors; +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL

mysql查看表结构

mysql>show columns from ap_record;