declare cnt number:=0; begin insert into a select * from b; cnt:=cnt+1; if cnt>5000 then commit; end if; exception when others then rollback; end;
declare cnt number:=0; cursor cur is select * from b; rs cur%rowtype; begin open cur; loop fetch cur in rs insert into a values(rs.id); cnt:=cnt+1; if cnt>5000 then commit; end if; end loop; exception when others then rollback; end;
cnt number:=0;
begin
insert into a select * from b;
cnt:=cnt+1;
if cnt>5000 then
commit;
end if;
exception
when others then
rollback;
end;
cnt number:=0;
cursor cur is select * from b;
rs cur%rowtype;
begin
open cur;
loop
fetch cur in rs
insert into a values(rs.id);
cnt:=cnt+1;
if cnt>5000 then
commit;
end if;
end loop;
exception
when others then
rollback;
end;
你要插入的数据表是什么样子的?
有没有 分区 或者索引之类的东西 可以考虑 用分区 或索引 添加的时候 /*+append*/