[英]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.