mysql 查询某个数据库中某个表的所有列名

查询某个数据库中某个表的所有列名

 
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'tb_name'; 

查询某个数据库中某个表的所有列名,并用逗号连接

 
SELECT GROUP_CONCAT(COLUMN_NAME SEPARATOR ",") FROM information_schema.COLUMNS 
WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'tb_name';
posted @ 2021-12-16 10:03  刘小吉  阅读(758)  评论(0编辑  收藏  举报