I tried with sql loader.The thing is the table needs to be empty for data loading.Is there any way to do data upload without truncating the table.The CSV data need to be appended in the table.i am using oracle 11g.
SQL*Loader is the primary method for quickly populating Oracle tables with data from external files. It has a powerful data parsing engine that puts little limitation on the format of the data in the datafile. SQL*Loader is invoked when you specify the sqlldr command or use the Enterprise Manager interface.
The SQL*Loader documentation says:
When you are loading a table, you can use the
INTO TABLE
clause to specify a table-specific loading method (INSERT
,APPEND
,REPLACE
, orTRUNCATE
) that applies only to that table. That method overrides the global table-loading method. The global table-loading method isINSERT
, by default, unless a different method was specified before anyINTO TABLE
clauses.
So by default your table load will be in INSERT
mode, which does require the table to be empty.
The documentation also explains how to load data into a non-empty table; in your case you want to preserve the existing data:
APPEND
If data already exists in the table, then SQL*Loader appends the new rows to it. If data does not already exist, then the new rows are simply loaded. You must haveSELECT
privilege to use theAPPEND
option.
So your control file will need to say something like this (as shown in their example):
LOAD DATA
INFILE 'my_file.dat'
BADFILE 'my_file.bad'
DISCARDFILE 'my_file.dsc'
APPEND
INTO TABLE my_table
...
You could also consider using the new CSV data as an external table and inserting to your real table from that, which might be a bit more flexible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With