mysql create store procedure for loops, and with parameters respectively
drop procedure if exists insert_into_t2_sp; DELIMITER // CREATE PROCEDURE insert_into_t2_sp() BEGIN DECLARE i INT DEFAULT 2; WHILE (i <= 1000000) DO INSERT INTO `t2` (id) values (i); SET i = i+1; END WHILE; END; //
DELIMITER ; CALL insert_into_t2_sp(); drop procedure if exists insert_into_t3_sp; DELIMITER // CREATE PROCEDURE insert_into_t3_sp (IN id_value bigint unsigned) BEGIN while(id_value<1000) do insert into t3(id) values(id_value); set id_value=id_value+1; end while; END; // DELIMITER ; call insert_into_t3_sp(1);