Created
July 24, 2018 01:33
-
-
Save kentatogashi/601722e8b76ea360cbdbc7909cf1a243 to your computer and use it in GitHub Desktop.
MySQLで、ランダムな文字列を挿入するだけのプロシージャ ref: https://qiita.com/kentatogashi/items/6c24a5460bb7f3f9a930
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
CREATE TABLE `test` (id INT(11) NOT NULL AUTO_INCREMENT, string VARCHAR(32), created_date TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
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 // | |
CREATE PROCEDURE f(n INT) | |
BEGIN | |
DECLARE i int DEFAULT 0; | |
WHILE i < n DO | |
INSERT INTO `test` (`string`) SELECT MD5(RAND()); | |
SET i = i + 1; | |
END WHILE; | |
END // | |
DELIMITER ; |
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
CALL f(1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
インデックスをあり、なしの際の速度検証