Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Forall insert Vs Direct insert

user4295847Jul 2 2013 — edited Jul 3 2013

Hi ,

Find the below two codes which are doing same logic...Consider product table has 10,000 rows..
Please advice me which one give the better performance and Why ?


Code 1
-----------------
DECLARE
TYPE prod_tab IS TABLE OF products%ROWTYPE;
products_tab   prod_tab := prod_tab();
BEGIN

SELECT * BULK COLLECT INTO products_tab FROM products;

FORALL i in products_tab.first .. products_tab.last
INSERT INTO products_history VALUES products_tab(i);
COMMIT;
END;

Code2:
-------------

INSERT /*+ APPEND*/ INTO products_history (product_id,product_name)
select product_id,product_name from products;
COMMIT;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2013
Added on Jul 2 2013
15 comments
2,293 views