Best way to bulk insert data into Oracle database
I am going to create a lot of data scripts such as INSERT INTO and UPDATE
There will be 100,000 plus records if not 1,000,000
What is the best way to get this data into Oracle quickly? I have already found that SQL Loader is not good for this as it does not update individual rows.
Thanks
UPDATE: I will be writing an application to do 开发者_JS百科this in C#
Load the records in a stage table via SQL*Loader. Then use bulk operations:
- INSERT INTO SELECT (for example "Bulk Insert into Oracle database")
- mass UPDATE ("Oracle - Update statement with inner join")
- or a single MERGE statement
To keep It as fast as possible I would keep it all in the database. Use external tables (to allow Oracle to read the file contents), and create a stored procedure to do the processing.
The update could be slow, If possible, It may be a good idea to consider creating a new table based on all the records in the old (with updates) then switch the new & old tables around.
How about using a spreadsheet program like MS Excel or LibreOffice Calc? This is how I perform bulk inserts.
- Prepare your data in a tabular format.
- Let's say you have three columns, A (text), B (number) & C (date). In the D column, enter the following formula. Adjust accordingly.
="INSERT INTO YOUR_TABLE (COL_A, COL_B, COL_C) VALUES ('"&A1&"', "&B1&", to_date ('"&C1&"', 'mm/dd/yy'));"
精彩评论