1、查詢當前使用的數據庫
select database();
2、獲取當前數據庫表
select * from information_schema.TABLES where TABLE_SCHEMA=(select database())
第二種方法,不能使用union all 等方式。
show full columns from table_name
3、獲取表中字段
select * from information_schema.COLUMNS where table_name = 'table_name' and table_schema = (select database());
4、使用一個表結構創建新表
CREATE TABLE IF NOT EXISTS `table_name` like `new_table_name`