查询某个数据库中某个表的所有列名
1 2 |
SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'tb_name'; |
查询某个数据库中某个表的所有列名,并用逗号连接
1 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(表名)
MySQL数据库查询所有表名
1 |
show tables; |
1 |
select table_name from information_schema.tables where table_schema='db_name'; |
注:替换db_name为自己的数据库名
from: https://blog.csdn.net/qzw985/article/details/122209484