使用 .NET 批量插入 Oracle [英] Bulk Insert to Oracle using .NET

查看:34
本文介绍了使用 .NET 批量插入 Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 .NET 对 Oracle 进行批量插入的最快方法是什么?我需要使用 .NET 将大约 160K 记录传输到 Oracle.目前,我正在使用插入语句并执行 160K 次.大约需要 25 分钟才能完成.源数据存储在一个DataTable中,作为从另一个数据库(MySQL)查询的结果,

What is the fastest way to do Bulk insert to Oracle using .NET? I need to transfer about 160K records using .NET to Oracle. Currently, I'm using insert statement and execute it 160K times.It takes about 25 minutes to complete. The source data is stored in a DataTable, as a result of query from another database (MySQL),

有没有更好的方法来做到这一点?

Is there any better way to do this?

编辑:我目前正在使用 System.Data.OracleClient,但愿意接受使用其他提供商(ODP.NET、DevArt 等)的解决方案

EDIT : I'm currently using System.Data.OracleClient, but willing to accept solutions using another provider (ODP.NET, DevArt, etc..)

推荐答案

我正在使用 ODP.NET 中的数组绑定在 15 秒左右的时间内加载 50,000 条记录

I'm loading 50,000 records in 15 or so seconds using Array Binding in ODP.NET

它的工作原理是重复调用您指定的存储过程(您可以在其中执行更新/插入/删除),但它会将多个参数值从 .NET 批量传递到数据库.

It works by repeatedly invoking a stored procedure you specify (and in which you can do updates/inserts/deletes), but it passes the multiple parameter values from .NET to the database in bulk.

不是为存储过程的每个参数指定一个值,而是为每个参数指定一个数组值.

Instead of specifying a single value for each parameter to the stored procedure you specify an array of values for each parameter.

Oracle 将参数数组从 .NET 一次性传递到数据库,然后使用您指定的参数值重复调用您指定的存储过程.

Oracle passes the parameter arrays from .NET to the database in one go, and then repeatedly invokes the stored procedure you specify using the parameter values you specified.

http://www.oracle.com/technetwork/issue-archive/2009/09-sep/o59odpnet-085168.html

/达米安

这篇关于使用 .NET 批量插入 Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆