+
81
-

mysql获取所有数据库所有表及字段的sql语句怎么写?

近日项目有需求,mysql获取所有数据库所有表及字段的sql语句怎么写?

网友回复

+
1
-

1、获取所有数据库

show databases;

2、获取某个数据库的所有表

select table_name from information_schema.tables where table_schema='数据库名'

3、获取某个表的所有字段结构

select column_name from information_schema.columns where table_schema='数据库名' and table_name='表名';

我知道答案,我要回答