大表分批删除脚本之MySQL版
时间:2021-07-01 10:21:17
帮助过:32人阅读
delimiter $$
2 drop procedure if exists proc_delete_old_data;
3 create procedure proc_delete_old_data()
4 begin
5 lp : loop
6 delete from mytable
where createdtime
<= date_sub(curdate(),interval
1 month) limit
5000;
7 if row_count()
< 5000 then
8 leave lp;
9 end if;
10 select sleep(
1);
11 end loop;
12 end $$
13
14 delimiter ;
15 set binlog_format
= STATEMENT;
16 call proc_delete_old_data;
本文地址:http://www.cnblogs.com/ajiangg/p/6604317.html
大表分批删除脚本之MySQL版
标签:font bin oop form stat sql call server creat