MySQL批量刪除指定字首表

2022-03-27 01:19:58 字數 661 閱讀 5433

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

MySQL批量刪除指定字首表

mysql批量刪除指定字首表 select concat drop table table name,from information schema.tables where table name like dede dede 為要刪除的表字首,執行此sql語句後會生成一串sql語句,必須再執行生成...

MySQL中批量刪除指定字首表的sql語句

想要實現mysql drop table like prefix 沒有直接可用的命令,不過可以通過mysql語法來組裝,sql view plain copy select concat drop table group concat table name as statement from inf...

Mysql 批量刪除字首或者字尾表

oracl有drop table like 的用法,但是mysql沒有,可以寫指令碼 不做贅述 也可以組裝sql。注意,我的資料庫名字是test,有個表叫data,然後我準備四個有相同字首的表,批量刪除,準備資料可以用這條sql create table test 1201 select from ...