delimiter //
drop procedure IF EXISTS borrow1;
create procedure borrow1()
BEGIN
declare var int;
set var=120;
while var<220 do
INSERT INTO borrow VALUES (var,'123456', null, 'E00401502B33832C', '经济法学', null, '张三', '1626368311', '30', '2021-06-26 09:42:57', '2021-07-26 09:42:57', null, null, '0', '0', '2021-04-26 09:42:57', null, null);
set var=var+1;
end while;
end;
//
delimiter;
call borrow1();
create procedure borrow2()
begin
DECLARE i INT DEFAULT 1;
WHILE (i <= 1000) DO
INSERT INTO borrow(isbn,user_no,rfid,bookname,local,user,uid,day,bdate,cdate,cclass,types,numbers,state,borrow_date,return_date,renew) VALUES ('123456', null, 'E00401502B33832C', '经济法学', null, '张三', '1626368311', '30', '2021-06-26 09:42:57', '2021-07-26 09:42:57', null, null, '0', '0', '2021-04-26 09:42:57', null, null);
SET i = i + 1;
END WHILE;
end;
call borrow2();
-- -- 创建完了记得删除储存过程,避免不必要的bug
drop procedure borrow2
在这里插入代码片
MySql实现存储过程批量添加数据
最新推荐文章于 2024-06-04 09:48:22 发布