Random number seed

Last modified 12 months ago

Summary

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

Code

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();