方法1:
---建立测试数据表
user test
create table t(id int,name char(20));
delimiter
SETAUTOCOMMIT=0
create procedure test1()
begin
declare v_cnt decimal (10) default 0 ;
dd:loop
insert into t values(2,'xxxxxxxx');
set v_cnt = v_cnt+10 ;
if v_cnt = 10000 then leave dd;
end if;
end loop dd ;
commit;
end;$$
delimiter ;
call test1;
--为了测试回滚段大事物,关闭自动提交功能
mysql> set global AUTOCOMMIT = 0;
mysql> select count(*) from t;
+-------------+
| 1066367 |
+-------------+
1 row in set (0.45 sec)
方法2:
后续追加