Bulk Insert into Oracle database: Which is better: FOR Cursor loop or a simple Select?

前端 未结 8 1377
广开言路
广开言路 2020-12-04 22:32

Which would be a better option for bulk insert into an Oracle database ? A FOR Cursor loop like

DECLARE
   CURSOR C1 IS SELECT * FROM FOO;
BEGIN
   FOR C1_R         


        
8条回答
  •  眼角桃花
    2020-12-04 22:56

    A simple insert/select like your 2nd option is far preferable. For each insert in the 1st option you require a context switch from pl/sql to sql. Run each with trace/tkprof and examine the results.

    If, as Michael mentions, your rollback cannot handle the statement then have your dba give you more. Disk is cheap, while partial results that come from inserting your data in multiple passes is potentially quite expensive. (There is almost no undo associated with an insert.)

提交回复
热议问题