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`