MySQL存储过程之简单批量造数据

1.创建一个test_batchInsert的存储过程
delimiter $$$
create procedure test_batchInsert(in j int)
begin
declare i int default 0;
set i=0;
start transaction;
while i<j do
INSERT INTO table_name (id,name,create_time) VALUES (REPLACE(uuid(),"-",""),CONCAT("名字",i),current_timestamp())
set i=i+1;
end while;
commit;
end
$$$
delimiter;
2.运行存储过程

call test_batchInsert(20);

3.查询所有存储过程

SHOW PROCEDURE STATUS;

4.删除存储过程

drop procedure test_batchInsert;

posted @ 2022-12-23 17:06  土豆兮  阅读(55)  评论(0)    收藏  举报