使用ADO插入许多记录 [英] Insert many records using ADO

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

问题描述

我正在寻找使用 ADO 一次将多个记录(+1000)一次插入表中的最快方法。

I am looking the fastest way to insert many records at once (+1000) to an table using ADO.

选项:


  1. 使用插入命令和参数

  1. using insert commands and parameters

ADODataSet1.CommandText:='INSERT INTO .....';    
ADODataSet1.Parameters.CreateParameter('myparam',ftString,pdInput,12,''); 
ADODataSet1.Open;


  • 使用 TAdoTable

    AdoTable1.Insert;
    AdoTable1.FieldByName('myfield').Value:=myvale;
    //..
    //..
    //..
    AdoTable1.FieldByName('myfieldN').value:=myvalueN;
    AdoTable1.Post;
    


  • 我正在使用delphi 7,ADO和ORACLE。

  • I am using delphi 7, ADO, and ORACLE.


    推荐答案

    使用ADO我认为您可能不走运。并非所有后端都支持批量插入操作,因此ADO实现了一种抽象以允许对明显批量操作(批处理)进行一致的编码,而不考虑后端支持(幕后只是插入对象)。

    Using ADO I think you may be out of luck. Not all back-ends support bulk insert operations and so ADO implements an abstraction to allow consistent coding of apparent bulk operations (batches) irrespective of the back-end support which "under the hood" is merely inserting the "batch" as a huge bunch of parameterised, individual inserts.

    这样做的缺点是,即使那些支持批量插入的后端也不会始终将其编码为他们的ADO / OLEDB提供者-为什么要打扰? (我已经看到它提到Oracle OLEDB提供程序支持批量操作,而ADO拒绝了它的访问,因此ADO框架甚至有可能根本不允许提供程序在ADO本身中更直接地支持此功能-我不确定)。

    The downside of this is that even those back-ends which do support bulk inserts do not always code this into their ADO/OLEDB provider(s) - why bother? (I've seen it mentioned that the Oracle OLEDB provider supports bulk operations and that it is ADO which denies access to it, so it's even possible that the ADO framework simply does not allow a provider to support this functionality more directly in ADO itself - I'm not sure).

    但是,您提到了Oracle,这个后端肯定确实通过其本地API支持批量插入操作。 。

    But, you mention Oracle, and this back-end definitely does support bulk insert operations via it's native API's.

    有一个商业的Delphi组件库-ODAC( Oracle Direct Access组件),用于直接访问Oracle(甚至不需要安装Oracle客户端软件)

    这也直接支持Oracle提供的批量插入功能,并且是访问Oracle数据存储的一种高效方式。

    This also directly supports the bulk insert capabilities provided by Oracle and is additionally a highly efficient means for accessing your Oracle data stores.

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

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