MySQL 批量插入表数据的存储过程写法记录

写法记录

1
2
3
4
5
6
7
8
9
10
CREATE PROCEDURE insert_bulk(in max_num int(10))
begin
declare i int default 0;
set autocommit = 0;
repeat
set i = i + 1;
INSERT INTO `table`(xxx) VALUES (xxx);
until i = max_num end repeat;
commit;
end;

调用

1
call insert_bulk(10000)