简体   繁体   English

如何使用C#从Oracle数据库检索大数据?

[英]How to retrieve large data from Oracle database using C#?

I am trying to retrieve a large amount of data from an Oracle database in .NET. 我正在尝试从.NET中的Oracle数据库检索大量数据。 I am using a .NET DBDataReader which is working fine with small amount of data but when the data become medium or large it stops functioning and I have no idea why. 我正在使用.NET DBDataReader ,它可以处理少量数据,但是当数据变大或变大时它将停止运行,我也不知道为什么。 How can i retrieve large amount of data? 我如何检索大量数据?

You should try using ODP.NET . 您应该尝试使用ODP.NET That is Oracle Data Provider written for .NET and it's much better optimized for communication with Oracle databases. 那是为.NET编写的Oracle数据提供程序,为与Oracle数据库的通信进行了更好的优化。

Microsoft deprecated Oracle Client (System.Data.OracleClient) ( http://blogs.msdn.com/adonet/archive/2009/06/15/system-data-oracleclient-update.aspx ) and advised to use 3rd hand tools. Microsoft不推荐使用Oracle Client(System.Data.OracleClient)( http://blogs.msdn.com/adonet/archive/2009/06/15/system-data-oracleclient-update.aspx ),建议使用第三手工具。

EDITED: 编辑:

Maby you should take a look at this similar question and answer: Big Performance Problems With Oracle DataReader in .Net Maby您应该看看这个类似的问题和答案: .Net中Oracle DataReader的重大性能问题

Ok, since you are expecting answers related to your question with very little information, answering these would help OTHERS to answer your question: 好的,由于您希望获得与问题相关的答案的信息很少,因此回答这些问题将有助于其他人回答您的问题:

1- What is your data type in database 1-您在数据库中的数据类型是什么

2- How are you trying to fetch the data (Some code would help a lot) 2-您如何尝试获取数据(某些代码会很有帮助)

3- Are there any indexes, how big is the table and how complex is your query, have you tried optimizing it? 3-是否有索引,表有多大,查询有多复杂,您是否尝试过对其进行优化? Try writing your query. 尝试编写查询。

... ...


Ok, here is what you can try and tell us if it changed anything... 好的,这是您可以尝试告诉我们的内容是否有所改变的方法...

static void DownloadBlob(OracleConnection myConnection)
{
  OracleCommand myCommand = new OracleCommand("SELECT * FROM table", myConnection);
  myConnection.Open();
  OracleDataReader myReader = myCommand.ExecuteReader(System.Data.CommandBehavior.Default);
  try
  {
    while (myReader.Read())
    {
      //Obtain OracleLob directly from OracleDataReader
      OracleLob myLob = myReader.GetOracleLob(myReader.GetOrdinal("Ordinal"));
      if (!myLob.IsNull)
      {
        // I hope it is BLOB :)
      }
    }
  }
  finally
  {
    myReader.Close();
    myConnection.Close();
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 C# 从数据库中检索数据 - Retrieve data from database using C# 如何在没有数据适配器的 c# windows 应用程序中从 oracle 数据库中检索数据 - How to retrieve data from oracle database in c# windows application without data adapter 使用C#中的imagepath从Oracle数据库检索图像 - To retrieve image from oracle database by using imagepath in c# 使用C#从oracle数据库读取大量数据并将其导出为.dat文件 - Reading large volume of data from oracle database and export it as .dat file using C# 如何使用C#Web应用程序从Oracle数据库检索图像? - How to retrieve image from Oracle database using C# web application? 如何从一个Oracle的数据库中取出多个表的数据,创建一个数据表,然后将这些数据存储在C#的一个class object中? - How to retrieve data from multiple tables from an Oracle database, create a datatable and then store this data in a class object in C#? 使用C#中的ADODB将数据从数据库检索到文本框 - Retrieve Data from Database to Textbox using ADODB in C# 无法使用C#从数据库检索数据 - Can't retrieve data from database using c# 在 C# 中使用 ADODB 从数据库中检索数据 - Retrieve Data From Database Using ADODB in C# 使用C#将数据从数据集移动到Oracle数据库 - Moving Data from DataSet to Oracle Database using C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM