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

 我来答
Mei_陈先生
高粉答主

2023-05-02 · 关注我不会让你失望
知道答主
回答量:162
采纳率:100%
帮助的人:4.8万
展开全部

查询 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';

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式