将数据批量插入 Oracle 数据库的最佳方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7306405/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:30:31  来源:igfitidea点击:

Best way to bulk insert data into Oracle database

oracleoracle10g

提问by Jon

I am going to create a lot of data scripts such as INSERT INTO and UPDATE

我将创建很多数据脚本,例如 INSERT INTO 和 UPDATE

There will be 100,000 plus records if not 1,000,000

如果不是 1,000,000,则将有 100,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.

将这些数据快速导入 Oracle 的最佳方法是什么?我已经发现 SQL Loader 对此不利,因为它不会更新单个行。

Thanks

谢谢

UPDATE:I will be writing an application to do this in C#

更新:我将在 C# 中编写一个应用程序来执行此操作

回答by Vincent Malgrat

Load the records in a stage table via SQL*Loader. Then use bulk operations:

通过SQL*Loader将记录加载到阶段表中。然后使用批量操作:

回答by Kevin Burton

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.

为了尽可能快地保存它,我会将它全部保存在数据库中。使用外部表(允许 Oracle 读取文件内容),并创建一个存储过程来进行处理。

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.

更新可能会很慢,如果可能的话,考虑根据旧表(有更新)中的所有记录创建一个新表,然后切换新旧表可能是个好主意。

回答by Shaakunthala

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

使用 MS Excel 或 LibreOffice Calc 等电子表格程序怎么样?这就是我执行批量插入的方式。

  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.
  1. 以表格格式准备数据。
  2. 假设您有三列,A(文本)、B(数字)和 C(日期)。在 D 列中,输入以下公式。相应调整。

="INSERT INTO YOUR_TABLE (COL_A, COL_B, COL_C) VALUES ('"&A1&"', "&B1&", to_date ('"&C1&"', 'mm/dd/yy'));"

="INSERT INTO YOUR_TABLE (COL_A, COL_B, COL_C) VALUES ('"&A1&"', "&B1&", to_date ('"&C1&"', 'mm/dd/yy'));"