Random number seed

Last modified 1 year ago
Danger icon
The last modifications of this post were around 1 year ago, some information may be outdated!


This script will seed random numbers into the table columns needed.


drop procedure if exists load_foo_test_data;

delimiter #
create procedure load_foo_test_data()

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;
end #

delimiter ;

call load_foo_test_data();