Best way to bulk insert data into Oracle database

折月煮酒 提交于 2019-12-06 03:06:59

问题


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 this in C#


回答1:


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



回答2:


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.




回答3:


How about using a spreadsheet program like MS Excel or LibreOffice Calc? This is how I perform bulk inserts.

  1. Prepare your data in a tabular format.
  2. 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'));"



来源:https://stackoverflow.com/questions/7306405/best-way-to-bulk-insert-data-into-oracle-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!