--建立測試表create tablebulk_objectstablespace usersasselect object_name, object_type from dba_objects;--定義模擬批次所需變數DECLARETYPE t_tab IS TABLE OF bulk_objects%ROWTYPE;objects_tab t_tab := t_tab();start_time number; end_time number;BEGINSELECT *BULK COLLECT INTO objects_tabFROM bulk_objects;--模擬批次取數插入Start_time := DBMS_UTILITY.get_time;FORALL i in objects_tab.first .. objects_tab.lastINSERT INTO bulk_objects VALUES objects_tab(i);end_time := DBMS_UTILITY.get_time;DBMS_OUTPUT.PUT_LINE("Conventional Insert: "||to_char(end_time-start_time));COMMIT;END;/--可見開啟批次的運算子關鍵在於:BULK COLLECT,FORALL--如果是高階語言的話、關鍵是構造並傳遞能對映到相應TYPE的table陣列到後臺。
--建立測試表create tablebulk_objectstablespace usersasselect object_name, object_type from dba_objects;--定義模擬批次所需變數DECLARETYPE t_tab IS TABLE OF bulk_objects%ROWTYPE;objects_tab t_tab := t_tab();start_time number; end_time number;BEGINSELECT *BULK COLLECT INTO objects_tabFROM bulk_objects;--模擬批次取數插入Start_time := DBMS_UTILITY.get_time;FORALL i in objects_tab.first .. objects_tab.lastINSERT INTO bulk_objects VALUES objects_tab(i);end_time := DBMS_UTILITY.get_time;DBMS_OUTPUT.PUT_LINE("Conventional Insert: "||to_char(end_time-start_time));COMMIT;END;/--可見開啟批次的運算子關鍵在於:BULK COLLECT,FORALL--如果是高階語言的話、關鍵是構造並傳遞能對映到相應TYPE的table陣列到後臺。