将oracle迁移到SQL Server - null vs empty [英] Migration oracle to SQL server - null vs empty

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

问题描述

我们已将Oracle数据库转换为SQL Server数据库。我们面临的问题是null与空白。



场景:



oracle:



创建表Student(Sno int,FName varchar(20)not null,MName varchar(30)null,

Lname varchar(20)not null)



插入学生(Sno,Fname,Mname,Lname)值(10,'James','','Clark')



记录插入Oracle作为中间名插入为空即使我们传递空白值('')

10,James,null,Clark



记录插入到SQL Server中作为中间名在SQL服务器中显示为空白(显示表中的空白区域,即使我们有默认约束)

10,James, ,Clark





当空白('')插入SQL表时我们要处理它应该被视为'null',这是Oracle数据库的类似行为。



我尝试过:



对于某些现有的t装配工增加了条件nullif。但有些表我们没有触发器以及如何在插入或更新时处理这些表。

We have converted Oracle database to SQL server database. We are facing issue with null vs blank.

Scenario:

In oracle:

Create table Student (Sno int, FName varchar(20) not null, MName varchar(30) null,
Lname varchar(20) not null)

Insert into Student(Sno,Fname,Mname,Lname) values (10,'James' ,'','Clark')

Record Inserting into Oracle as Middle name inserting as null even we passed blank value('')
10,James,null,Clark

Record Inserting into SQL Server as Middle name inserting as blank in SQL server (showing empty space in the table, even we have the default constraint)
10,James,,Clark


we want to handle when blank ('') inserting into SQL table it should be treated as 'null' which is the similar behavior of Oracle database.

What I have tried:

for some existing triggers added condition nullif. but some of the table we don't have triggers and how to handle those tables when insert or update happening.

推荐答案

这是一个已知的Oracle问题(这是一个从角度来看,但SQL-92不同意甲骨文,但甲骨文说他先在这里)...

Oracle威胁空字符串为NULL值(这是一个内部对话)。

我不建议强制SQL威胁空字符串,因为Oracle有两个原因:

1. ANSI SQL表示Oracle错误

2.它将成为带有大量字符串变量的插入的性能

但是如果你不能跳过其中一个:

1.使用触发器

2。在SQL中包装插入

3.在应用程序中更改INSERT代码
It is a known Oracle problem (well that's a point of view, but SQL-92 disagrees with Oracle, but Oracle says he was here first)...
Oracle threat empty string as NULL value (it is an internal conversation).
I would not advise to force SQL to threat empty string as Oracle does for two reasons:
1. ANSI SQL says Oracle wrong
2. It will became a performance with large number of inserts with string variables
However if you can not skip one of these:
1. use triggers
2. wrap insert in SQL
3. change INSERT code in application


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

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