Home > Database > Mysql Tutorial > body text

MySQL批量删除指定前缀表_MySQL

WBOY
Release: 2016-06-01 13:32:36
Original
928 people have browsed it

bitsCN.com

Select CONCAT( 'drop table ', table_name, ';' ) FROM information_schema.tables Where table_name LIKE 'dede_%';
Copy after login

  "dede"为要删除的表前缀,执行此SQL语句后会生成一串SQL语句,必须再执行生成的这些SQL语句才能真正执行删除操作

  另外一个就是批量修改表名:

Select CONCAT( 'ALTER TABLE ', table_name, 'RENAME TO ', table_name,';' ) FROM information_schema.tables Where table_name LIKE 'dede_%';
Copy after login

  首先执行此SQL语句,会生成如下语句:

ALTER TABLE de_aaa RENAME TO de_aaa; ALTER TABLE de_bbb RENAME TO de_bbb;
Copy after login

  在编辑器中将“RENAME TO de”批量改为想设置的表前缀,再执行此SQL语句即可批量修改表名。

bitsCN.com
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template