MySQL获取某个表的所有字段名

标签:,
来源: 老季博客
日期: 2019-8-9
作者: 腾讯云/服务器VPS推荐评测/Vultr
阅读数: 51
select COLUMN_NAME from information_schema.COLUMNS where table_name = 'your_table_name';

如果多个数据库中存在你想要查询的表名,那么查询的结果会包括全部的字段信息。通过DESC information_schema.COLUMNS可以看到该表中列名为TABLE_SCHEMA是记录数据库名,因此下面的写法更为严格

select COLUMN_NAME from information_schema.COLUMNS where table_name = 'table_name' 
and table_schema = 'db_name';
链接到文章: https://jiloc.com/46135.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注