【Mysql】查询/获取所有表结构

1. 查询当前所在数据库所有表信息

select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables where table_schema = (select database()) order by create_time desc

在这里插入图片描述

select database(),当前数据库名称:
在这里插入图片描述

2.获取单个建表语句:

SHOW CREATE TABLE '表名'

在这里插入图片描述

3. 查询表中所有字段的属性(字段类型,名称,长度,描述,是否可空)(table_name=‘表名’)

select column_name, is_nullable, data_type, column_comment, column_key, extra from information_schema.columns 
where table_name = 'test' and table_schema = (select database()) order by ordinal_position 

猜你喜欢

转载自blog.csdn.net/Mr_ShangCL/article/details/107659899