将数据从Oracle复制到SQL Server的速度更快?

时间:2015-12-10 07:09:53

标签: c# sql-server database oracle sqlbulkcopy

我一直在尝试使用以下代码将数据(80000行,105列)从Oracle复制到SQL Server:

OracleConnection oraCon = new OracleConnection(ORACLE_CONNECTION_STR); 
oraCon.Open();                
OracleCommand cmd = new OracleCommand();
cmd.Connection = oraCon;
cmd.CommandText = packageName;
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter param1 = cmd.Parameters.Add(PARAM_YEAR_TERM, OracleDbType.Int32);
param1.Direction = ParameterDirection.Input;
param1.Value = yearTerm;        
OracleParameter param2 = cmd.Parameters.Add(PARAM_RESULT, OracleDbType.RefCursor);
param2.Direction = ParameterDirection.Output;
OracleDataReader reader = cmd.ExecuteReader();    
SqlConnection sqlCon = new SqlConnection(SQL_CONNECTION_STR);
sqlCon.Open();               
SqlBulkCopy bulk = new SqlBulkCopy(sqlCon);
bulk.BulkCopyTimeout = 10000;
bulk.BatchSize = 5000;                
bulk.DestinationTableName = string.Format("dbo.{0}", tableName);               
bulk.WriteToServer(reader);

我更改了各种BatchSize并尝试了但至少需要10分钟。你有什么想让它更快吗?

0 个答案:

没有答案