mysql create 1 million test records

To create a lot of records for testing is possible using PROCEDURE like this:

DELIMITER //
drop procedure if exists gen //
CREATE TABLE mytable ( code int, a int, b int ) //
CREATE PROCEDURE gen() BEGIN DECLARE i int DEFAULT 0; WHILE i <= 1000000 DO INSERT INTO mytable (code, a, b) VALUES (i, 1, 1); SET i = i + 1; END WHILE; END //
CALL gen() //
DELIMITER ;

Leave a Reply

Your email address will not be published. Required fields are marked *