mysql 循环实例

drop procedure if exists insertMethod;
create procedure insertMethod(count int)
begin
		declare i int default 1;
		loop_name:loop -- 循环开始
				if i > count then 
						leave loop_name;  -- 判断条件成立则结束循环
				end if;
				INSERT INTO `user_5` ( `name`, `no`) VALUES ('test',CONCAT('T',UUID_SHORT()));
				set i=i+1;
		end loop;  -- 循环结束
end;
 -- 执行存储过程
call insertMethod(1000);

posted @ 2022-09-20 16:03  互联网-搬砖人  阅读(28)  评论(0)    收藏  举报