MySQL 批量删除table

转并修改自:https://www.cnblogs.com/init-007/p/10955110.html

原理:通过mysql语法组装批量删除的命令

SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) 
AS statement FROM information_schema.tables 
WHERE table_schema = 'database_name' AND table_name LIKE 'myprefix_%';

例如 这里要删除database thread 下的file-开头的table:

 select concat("drop table thread.",group_concat(table_name),";")
 as statement from information_schema.tables
 where table_schema="thread" and table_name like "file%";

 

 

 再执行生成的批量删除语句:

drop table thread.file1,file10,file100,file11,file12,file13,file14,file15,file16,file17,file18,file2,file3;

 

 

 

posted @ 2020-04-01 16:44  陈雪莲  阅读(780)  评论(0编辑  收藏  举报

welcome to myblog