Home  >  Article  >  Database  >  MySQL批量删除指定前缀表_MySQL

MySQL批量删除指定前缀表_MySQL

WBOY
WBOYOriginal
2016-06-01 13:32:36924browse

bitsCN.com

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语句即可批量修改表名。

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn