Insert some rows with random numbers from 1 to 5 in some columns.
Schema:
create table friday1
( id int auto_increment primary key,
value1 int not null,
value2 int not null
);
Insert 3 rows:
insert friday1(value1,value2) select floor(rand()*5)+1,floor(rand()*5)+1;
insert friday1(value1,value2) select floor(rand()*5)+1,floor(rand()*5)+1;
insert friday1(value1,value2) select floor(rand()*5)+1,floor(rand()*5)+1;
Stored Proc helper:
drop procedure if exists insertMany;
DELIMITER $$
create procedure insertMany
( howMany int
)
BEGIN
DECLARE soFar int default 0;
set howMany=least(howMany,500); -- max out at 500 regardless of IN parameter (RAND is slow)
WHILE soFar<howMany DO
insert friday1(value1,value2) select floor(rand()*5)+1,floor(rand()*5)+1;
set soFar=soFar+1;
END WHILE;
select soFar; -- # of times in loop
END$$
DELIMITER ;
Test:
call insertMany(200);
Results:
select count(*) as theCount,
least(min(value1),min(value2)) as theMin,
greatest(max(value1),max(value2)) as theMax
from friday1;
+----------+--------+--------+
| theCount | theMin | theMax |
+----------+--------+--------+
| 203 | 1 | 5 |
+----------+--------+--------+