Oracle Bulk Import

Jai picture Jai · Mar 7, 2014 · Viewed 8.5k times · Source

Bulk Import in Oracle

I have created the table emp and I need to import bulk data from a file into emp

For Ex

CREATE TABLE emp

( c1 NUMBER,

  c2 VARCHAR2(30)

)

File path : 'C:\Documents and Settings\TestUser\My Documents\LearnOracle\reports.csv'

Answer

Maheswaran Ravisankar picture Maheswaran Ravisankar · Mar 7, 2014

Write a Control file, say emp.ctl

load data
 options(direct=true)
insert
 into table emp
fields terminated by ',' optionally enclosed by '"' TRAILING NULLCOLS
 ( 
    c1 DECIMAL EXTERNAL,
    c2
)

Execute SQL*Loader as below.

sqlldr userid=user/pass@db data=reports.csv control=emp.ctl 

If you always want to refresh the table with your data completely. TRUNCATE the table and then load.

SQL*Loader is great utility that provide numerous options for performance. Kindly go through the documentation about DIRECT and CONVENTIONAL loading.

There's something called EXTERNAL tables, that might interest you as well. They use the flat file for the table data.