–创建测试表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数组到后台。