Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Created November 27, 2010 01:56
Show Gist options
  • Save xeoncross/717472 to your computer and use it in GitHub Desktop.
Save xeoncross/717472 to your computer and use it in GitHub Desktop.
MySQL sample proc showing insert loop
mysql> delimiter $$
mysql>
CREATE PROCEDURE myFunction()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE (i<=1000000) DO
INSERT into table (fk1_id, fk2_id, date) values (i, 1000000 - i, NOW());
SET i=i+1;
END WHILE;
END$$
mysql> delimiter ;
mysql> call myFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment