delimiter //
drop procedure if exists tq_order_clear;
CREATE PROCEDURE tq_order_clear()
BEGIN
DECLARE v_count BIGINT(15) DEFAULT 0;
DECLARE v_num BIGINT(6) DEFAULT 1;
insert into tq_order_h_test
SELECT *from tq_order_h_special where trade_day=20201016;
select count(0) into v_count from tq_order_h_special where trade_day=20201016;
select ( (v_count div 10000)+1 ) into v_num from dual;
while v_num >0 do
START TRANSACTION;
delete from tq_order_h_special where trade_day=20201016 limit 10000;
COMMIT;
set v_num=v_num-1;
end while;
END
//
call tq_order_clear();
mysql将表中的数据按条件筛除到另一张表
最新推荐文章于 2023-10-11 09:48:54 发布