1.使用批联编可以极大提高效率.
[@more@]
create or replace procedure batch
as
type bulk_type is table of emp_table%rowtype;
ref_bulk bulk_type;
type cursor_type is ref cursor return emp_table%rowtype;
c_bulk cursor_type;
begin
execute immediate 'truncate table emp_table_his';
open c_bulk for select * from emp_table;
loop
fetch c_bulk bulk collect into ref_bulk limit 250000;
forall i in 1..ref_bulk.count
insert into emp_table_his values ref_bulk(i);
commit;
exit when c_bulk%notfound;
end loop;
close c_bulk;
end;