要求:插入一张表(TESTMV)中三个字段(ID, GROUPID【组id】, USERID【用户id】),为了产生多个组,每个组多个人的数据,进行统计每个组多少人数据用
代码如下:
delete testmv;
create procdedure insertdb()
language SQL
begin
declare v_num int;
declare v_num1 int;
declare v_num2 varchar(12);
set v_num=0;
set v_num1=1;
loop1:
LOOP
if(v_num<100) then
set v_num = v_num +1;
set v_num1=1;
loop2:
LOOP
if(v_num1<=100) then
insert into testmv(ID, GROUPID, USERID) VALUES('id'||v_num||v_num1, 'groupid'||v_num, 'userid'||v_num||v_num1);
set v_num1=v_num1+1;
else
leave loop2;
end if;
end loop loop2;
else
leave loop1;
end if;
end loop loop1;
end;
call insertdb();
drop procedure insertdb();