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

前端 未结 8 1394
广开言路
广开言路 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:55

    I do neither for a daily complete reload of data. For example say I am loading my Denver site. There are other strategies for near real time deltas.

    I use a create table SQL as I have found is just almost as fast as a bulk load For example, below a create table statement is used to stage the data, casting the columns to the correct data type needed:

    CREATE TABLE sales_dataTemp as select cast (column1 as Date) as SALES_QUARTER, cast (sales as number) as SALES_IN_MILLIONS, .... FROM TABLE1;

    this temporary table mirrors my target table's structure exactly which is list partitioned by site. I then do a partition swap with the DENVER partition and I have a new data set.

提交回复
热议问题