Skip to content

Instantly share code, notes, and snippets.

@VTRyo
Created June 22, 2023 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VTRyo/9307046b2b6ded7054560dd2577a7ab2 to your computer and use it in GitHub Desktop.
Save VTRyo/9307046b2b6ded7054560dd2577a7ab2 to your computer and use it in GitHub Desktop.
This stored procedure is creating incremental dummy data in sample article table.
delimiter //
create procedure insert_loop(in x int)
begin
declare max_id int;
declare i int;
set i = 0;
select max(id) into max_id from article;
while i < x do
set i = i + 1;
insert into article values (max_id + i, concat('article', i), concat('body_', i));
end while;
end
//
delimiter ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment