-- 존재시 삭제

drop procedure if exists test;

 

 

-- sp 생성

delimiter $$

 

create procedure test()

begin

  set @i = 0;

 

  while @i < 100 do

    insert into dummpy (str) values('test');

    set @i = @i + 1;

  end while;

 

end$$

delimiter;

 

 

-- 실행

call test();

 

 

오래 걸리는 경우 mysql cli 로 실행을 걸어둔다.

# mysql-client 설치
sudo apt -y install mysql-client

# background 실행
mysql -u{아이디} -p{암호} -D{데이터베이스 이름} -h{DB 주소} -P{DB 포트} -e "call test();" > output.txt &