MySQL查询表的所有列名
(2022-10-15 21:06:02)分类: SQL |
MySQL 查询表的所有列名
1.查询某个数据库中某个表的所有列:
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'tb_name';
2.查询某个数据库中某个表的所有列名,并用逗号连接:
SELECT GROUP_CONCAT(COLUMN_NAME SEPARATOR ",") FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'tb_name';
注意:只需要替换db_name(数据库名)和tb_name(表名)
————————————————
原文链接:https://blog.csdn.net/CAI____NIAO/article/details/121532045