select CONCAT( 'drop table ', table_name, ';' )
from information_schema.tables
where table_name like 'dede_%';
"dede"
为要删除的表前缀,执行此SQL语句后会生成一串SQL语句,必须再执行生成的这些SQL语句才能真正执行删除操作
Select CONCAT( 'alter table ', table_name, 'rename to ', table_name,';' )
from information_schema.tables
where table_name like 'dede_%';
首先执行此SQL语句,会生成如下语句:
alter table de_aaa rename to de_aaa;
alter table de_bbb rename to de_bbb;
在编辑器中将rename to de
批量改为想设置的表前缀,再执行此SQL语句即可批量修改表名。
原文引用:https://www.cnblogs.com/haocool/archive/2013/06/25/3153984.html
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题:MySQL批量表操作