MySQL查询当前数据库所有表和表中字段

1、查询当前数据库

# 查询当前数据库
select database();

2、查询当前数据库所有表

# 查询当前数据中所有表
select table_name tableName,engine ,table_comment tableComment, create_time createTime 
from information_schema.tables
where table_schema = (select database()) 
order by create_time desc;

3、查询当前表所有字段

# 查询表中字段
select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns
where table_name = "pms_attr" and table_schema = (select database()) order by ordinal_position;

版权声明:本文为wqww_1原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。