网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > MySQL
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 180.125.107.111
Old 2014-07-04, 08:51 AM
Aledo Aledo is offline
初级会员
 
Join Date: 2006-02-07
Posts: 3
Aledo 现在声名狼藉
Default MySQL中批量删除指定前缀表的sql语句

有时候我们在安装一些cms的时候,这些cms都是带表前缀的方便区分数据,但有时候我们测试完需要删除的时候又有别的前缀表就可以参考下面的方法
Code:
Select CONCAT( 'drop table ', table_name, ';' ) 
FROM information_schema.tables 
Where table_name LIKE 'dede_%';
"dede"为要删除的表前缀,执行此SQL语句后会生成一串SQL语句,必须再执行生成的这些SQL语句才能真正执行删除操作

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

Code:
Select CONCAT( 'ALTER TABLE ', table_name, 'RENAME TO ', table_name,';' ) 
FROM information_schema.tables 
Where table_name LIKE 'dede_%';
首先执行此SQL语句,会生成如下语句:


Code:
ALTER TABLE de_aaa RENAME TO de_aaa; 
ALTER TABLE de_bbb RENAME TO de_bbb;
在编辑器中将“RENAME TO de”批量改为想设置的表前缀,再执行此SQL语句即可批量修改表名。
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 01:55 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.