AI智能
改变未来

【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.columnswhere table_name = \'test\' and table_schema = (select database()) order by ordinal_position
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » 【Mysql】查询/获取所有表结构