如何在以下步驟中以最佳方式在Oracle中插入超過一百萬行?如果我將FOR循環增加到一百萬行,它會掛起。在Oracle中插入一百萬行的最快方法
create or replace procedure inst_prc1 as
xssn number;
xcount number;
l_start Number;
l_end Number;
cursor c1 is select max(ssn)S1 from dtr_debtors1;
Begin
l_start := DBMS_UTILITY.GET_TIME;
FOR I IN 1..10000 LOOP
For C1_REC IN C1 Loop
insert into dtr_debtors1(SSN) values (C1_REC.S1+1);
End loop;
END LOOP;
commit;
l_end := DBMS_UTILITY.GET_TIME;
DBMS_OUTPUT.PUT_LINE('The Procedure Start Time is '||l_start);
DBMS_OUTPUT.PUT_LINE('The Procedure End Time is '||l_end);
End inst_prc1;
我不建議使用光標。光標會降低你的表現。 –
選中此鏈接(http://www.orafaq.com/wiki/Oracle_Row_Generator_Techniques) – haki