SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) AS statement FROM information_schema.tables WHERE table_schema = '替换成数据库名' AND table_name LIKE '替换表名前缀';
例子:
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) AS statement FROM information_schema.tables WHERE table_schema = 'my_system' AND table_name LIKE 'sales_info_bak%';
结果:
生成my_system库下匹配sales_info_bak前缀开头的所有表的删除脚本。