美文网首页
数据删除:按前缀批量删除表

数据删除:按前缀批量删除表

作者: hello大象 | 来源:发表于2017-12-04 17:54 被阅读0次

批量删除的预制作:

SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) AS statement FROM information_schema.tables WHERE table_schema = 'xda' AND table_name LIKE 'xda_event_2017%';

得到的sql语句:

+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DROP TABLE xda_event_20171128,xda_event_20171129,xda_event_20171130,xda_event_20171201,xda_event_20171202,xda_event_20171203,xda_event_20171204,xda_event_20171205; |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+

删除指定范围的记录
delete from xda_event_20171202 where event_id>10;

相关文章

网友评论

      本文标题:数据删除:按前缀批量删除表

      本文链接:https://www.haomeiwen.com/subject/hhcxixtx.html