MySQL5.6数据库获取指定schema下的表目录和字段明细

来源:互联网 发布:尚观mysql视频教程 编辑:程序博客网 时间:2024/05/16 19:23
MySQL数据库获取指定schema用户下的表目录和字段明细
INFORMATION_SCHEMA存放了数据库的很多元数据信息,比如数据库名、表、列、访问权限等信息,类似Oracle中的数据字典

--表目录
select
a.table_schema,
a.table_name,
a. engine,
a.table_rows,
a.table_comment
from
INFORMATION_SCHEMA.tables a
where
a.table_schema = 'test'
order by
table_name;

--字段明细
select
a.table_name,
a.table_comment,
b.column_name,
b.column_type,
b.column_comment
from
INFORMATION_SCHEMA.tables a,
INFORMATION_SCHEMA.columns b
where
a.table_schema = 'test'
and a.table_schema = b.table_schema
and a.table_name = b.table_name
order by
a.table_name,
b.ordinal_position;


阅读全文
0 0