怎样在sql中查询数据库的所有字段名

如题所述

查询 MySql 数据库中所有表名:

select table_name from information_schema.tables where table_schema='当前数据库名' and table_type='base table';

查询 MySql 指定数据库中指定表的所有字段名:

select column_name from information_schema.columns where table_schema='当前数据库名' and table_name='指定的表名';

扩展资料

查询所有数据库

show databases;

查询指定数据库中所有表名

select table_name from information_schema.tables where table_schema='database_name' and table_type='base table';

查询指定表中的所有字段名

查询指定表中的所有字段名和字段类型

select column_name,data_type from information_schema.columns where table_schema='database_name' and table_name='table_name';

温馨提示:答案为网友推荐,仅供参考