Created
March 22, 2019 21:06
-
-
Save banyek/1d76da53202f9e6c2d4b79ec46bda72b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
DROP PROCEDURE IF EXISTS duplicate_rows$$ | |
CREATE PROCEDURE duplicate_rows (IN tablename VARCHAR(255), IN times INT) | |
BEGIN | |
SET @statement = CONCAT(CONCAT(CONCAT(CONCAT("INSERT INTO ",tablename)," SELECT * FROM "),tablename),";"); | |
PREPARE stmt FROM @statement; | |
WHILE times > 0 DO | |
SELECT times as "Remaining"; | |
EXECUTE stmt; | |
SET times = times - 1; | |
END WHILE; | |
DEALLOCATE PREPARE stmt; | |
END | |
$$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment