Reputation: 1646
I have more than 1500 CSV files to load into Oracle 11gR2. I'm using sqlldr in Windows environment. I know i can load the file as follow, but it a really bad way for many reasons.
load data
infile 'FILE_1.csv'
infile 'FILE_2.csv'
infile 'FILE_3.csv'
infile 'FILE_4.csv'
infile 'FILE_5.csv'
.
.
.
infile 'FILE_1500.csv'
append
into table MyTable
fields terminated by ' '
trailing nullcols
(
A,
B,
C,
D,
E
F,
G
)
I'm looking for an automatic way to load a whole folder of files into the DB, file by file (I don't wan't to merge the files, since they are huge).
Any idea?
Upvotes: 1
Views: 147
Reputation: 49062
Use EXTERNAL TABLE
, pass the file names to it. On 11gR2
, you could use PREPROCESSOR DIRECTIVE.
You could even pass the file names dynamically. Have a look at this asktom link for more details https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3015912000346648463
Upvotes: 1