从Oracle迁移到MS SQL Server [英] Migrating from Oracle to MS sql server

查看:106
本文介绍了从Oracle迁移到MS SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果数据库平台从Oracle更改为SQL Server,则我的应用程序应该需要进行最少的更改.

我应该使用哪些DataReader对象来最大程度地减少将来对数据库平台的更改带来的影响?

A)IDataReader
B)OleDbDataReader

在此先谢谢您. .它们确实继承自IDataReader,因此在所有其他代码中,您无需区分.
尽管确实可以通过OleDb连接到SQL Server和Oracle,但我还是建议不要这样做.当要正确处理某些奇怪的数据类型(例如日期时间-尤其是本地化的-或guid等)时,OleDb太不确定了.
有些功能需要完全更改,例如


以我的经验,最好始终将框架提供的数据对象用于特定的数据库类型,例如用于SQL Server访问的SQL Server对象.

我不知道是否为Oracle提供了任何此类对象.


但是(这可能是不言而喻的,但是以防万一您不知道),您应该限制所有数据库对数据层的访问,并使代码与其余代码分开.这样,当(如果涉及)更改数据库类型时,您(或多或少)只需要更改"using"语句即可(甚至可以进行一些细微调整).

如果您的数据库代码遍布各处,那么这将成为一项主要任务...


Hi,

My application should needs to function with minimum of changes if the database platform ever changes from Oracle to SQL Server.

which DataReader objects should I use to minimize the impact of a change to the database platform in the future?

A) IDataReader
B) OleDbDataReader

Thanks in advance.

解决方案

Write a function which finds out which database your customer is using, then instantiate the specific type for it (i.e. OracleDataReader and SqlDataReader, resp.). They do inherit from IDataReader, hence in all the further code you need not differentiate.
Although it is true that you can connect to both SQL Server and Oracle via OleDb, I do recommend not to do so. OleDb is too unspecific when it comes to dealing correctly with some odd data types like datetime - especially localized - or guid etc.
Some functions need to be totally changed, e.g. bit operations, or getting the last insert id.


In my experience it''s always best to use the data objects provided by the framework for the specific database type, e.g. SQL Server objects for SQL server access.

I don''t know if any such objects are supplied for Oracle, though.


But (this might be selfevident, but just in case you don''t know it) you should restrict all your database access to your data layer and keep the code separate from the rest of the code. That way, when (if) it comes to changing the DB type, you (more or less) only need to change the "using" statement... (and perhaps make minor tweaks).

If your db code is spread all over the place, then this will become a major task...


这篇关于从Oracle迁移到MS SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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