Created
May 24, 2017 14:31
-
-
Save Dillie-O/bc5ee2d0da1c6bf212782b645834cc01 to your computer and use it in GitHub Desktop.
[Seed Random Data] Inserts random number range into table column #tags:mysql
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
drop procedure if exists load_foo_test_data; | |
delimiter # | |
create procedure load_foo_test_data() | |
begin | |
declare v_max int unsigned default 10; | |
declare v_counter int unsigned default 1; | |
declare v_min_rand int unsigned default 1; | |
declare v_max_rand int unsigned default 1; | |
truncate table job_category; | |
start transaction; | |
while v_counter < v_max do | |
insert into job_category (job_id, category_id) values (v_counter, FLOOR(v_min_rand + (RAND() * (v_max_rand - v_min_rand))) ); | |
set v_counter=v_counter+1; | |
end while; | |
commit; | |
end # | |
delimiter ; | |
call load_foo_test_data(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment