MySQL 查询表结构

最常用desc,查看表的列名信息

desc table_name;

查询建表语句获得更多表的信息

show create table table_name;
create table `student_info` (
    `student_id` int not null, 
    `student_name` varchar(30) not null, 
    `student_age` int not null
);

使用以上建表语句之后,再show create table table_name;获得的结果:

可以看到除了我们在建表语句定义的内容,还有ENGINE 以及 默认的字符集 信息。

还可以用下面的语句查看表状态的信息

show table status like 'student_info'\G

注意:student_info 用的是单引号,且语句末尾不需要分号

参考文章:

浅谈MySql的存储引擎(表类型)

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容