简体   繁体   中英

Oracle Bulk Insert Using SQL Developer

I have recently taken data dumps from an Oracle database. Many of them are large in size(~5GB). I am trying to insert the dumped data into another Oracle database by executing the following SQL in SQL Developer

@C:\path\to\table_dump1.sql;
@C:\path\to\table_dump2.sql;
@C:\path\to\table_dump3.sql;
             :

but it is taking a long time like more than a day to complete even a single SQL file.
Is there any better way to get this done faster?

SQL*Loader is my favorite way to bulk load large data volumes into Oracle. Use the direct path insert option for max speed but understand impacts of direct-path loads (for example, all data is inserted past the high water mark, which is fine if you truncate your table). It even has a tolerance for bad rows, so if your data has "some" mistakes it can still work.

SQL*Loader can suspend indexes and build them all at the end, which makes bulk inserting very fast.

Example of a SQL*Loader call:

$SQLDIR/sqlldr /@MyDatabase direct=false silent=feedback \
    control=mydata.ctl log=/apps/logs/mydata.log bad=/apps/logs/mydata.bad \
    rows=200000

And the mydata.ctl would look something like this:

LOAD DATA
INFILE '/apps/load_files/mytable.dat'
INTO TABLE my_schema.my_able
FIELDS TERMINATED BY "|"
 (ORDER_ID,
  ORDER_DATE,
  PART_NUMBER,
  QUANTITY)

Alternatively... if you are just copying the entire contents of one table to another, across databases, you can do this if your DBA sets up a DBlink (a 30 second process), presupposing your DB is set up with the redo space to accomplish this.

truncate table my_schema.my_table;

insert into my_schema.my_table
select * from my_schema.my_table@my_remote_db;

The use of the /* +append */ hint can still make use of direct path insert.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM