--IF <布尔表达式> THEN
--PL/SQL 和 SQL语句
--END IF;
-- LOOP
-- 要执行的语句;
-- EXIT WHEN <条件语句> --条件满足,退出循环语句
-- END LOOP;
declare
int NUMBER(5) :=0;
stuName student.sname%type;
sex student.ssex%type:='男';
begin
LOOP
stuName := 'name' || int;
if int mod 2 =0 then
sex :='男';
else
sex :='女';
end if;
int := int + 1;
INSERT INTO student values(sequence.nextval,stuName,sex,23);
exit when int =3000;
end loop;
end;
delete from student ;
commit;
---WHILE <布尔表达式> LOOP
-- 要执行的语句;
--END LOOP;
declare
num1 number(6) :=0;
begin
while num1 < 30000 loop
insert into student(SID,sname,ssex,sage) select sequence.nextval,'jake' || num1,'男',23 from dual;
num1 := num1 + 1;
end loop;
end;
commit;
rollback;
--[<<循环标签>>]
--FOR 循环计数器 IN [ REVERSE ] 下限 .. 上限 LOOP
-- 要执行的语句;
--END LOOP [循环标签];
declare
num1 number(6) :=0;
begin
for num1 in 0.. 3000 loop
insert into student(SID,sname,ssex,sage) select sequence.nextval,'jake' || num1,'男',23 from dual;
if num1 mod 100 =0 then
dbms_output.put_line('num1-->'|| num1);
end if;
end loop;
end;