方法1:[仅指定表名]
select COLUMN_NAME from information_schema.COLUMNS where table_name = 'your-table-name';
方法2:[指定表名+数据库名]
select COLUMN_NAME from information_schema.COLUMNS where table_name = 'your-table-name' and table_schema = 'your-DB-name';
========================那在mybatis中如何调用?====================
mapper.xml:
SELECT
COLUMN_NAME
FROM
information_schema.COLUMNS
WHERE
table_name = #{tableName};
mapper.java
List
调用即可获取!!
发表评论