Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DELIMITER $$
- CREATE DEFINER=`root`@`localhost` FUNCTION `random_str`() RETURNS char(16) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci
- BEGIN
- DECLARE chars varchar(16);
- DECLARE rs varchar(16);
- SET rs = '';
- SET chars = 'ABCDEF1234567890';
- WHILE (LENGTH(rs) < 16) DO
- SET rs = CONCAT(rs, SUBSTRING(chars, RAND() * LENGTH(chars), 1));
- END WHILE;
- RETURN rs;
- END$$
- CREATE DEFINER=`root`@`localhost` PROCEDURE `fill_test`(IN `cnt` INT UNSIGNED)
- NO SQL
- BEGIN
- DECLARE c int;
- DECLARE rs varchar(16);
- SET c = 0;
- while (c < cnt) DO
- set rs = random_str();
- INSERT INTO test_random_binary_codes (hash) VALUES (rs);
- set c = c + 1;
- end while;
- END$$
- DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement