Oracle 数据库中的 empty string 处理

跟 微软的数据库产品不一样, Oralce 把 '' 空的string 自动替换为 Null

所以下面的代码你可能考虑不一样的结果.

> create table suppliers
> ---
> ( supplier_id | number,
> supplier_name | varchar2(100));

Next, we'll insert two records into this table.

> insert into suppliers (supplier_id, supplier_name )
> values ( 10565, null ); > > insert into suppliers (supplier_id, supplier_name )
> values ( 10567, '' ); > > ** select * from suppliers
> where supplier_name = ''; //SQL server 中返回第二条记录,而 Oracle 返回空. ** > > ** 他会把NULL 等同 '' ** > > 所以 select * from suppliers
> where supplier_name is null; > > 返回所有的非空记录,包括null 和 '' > > 微软也有一篇KB Q225070 PRB: Oracle Servers Convert Empty Strings to NULL

Published At
Categories with Web编程
Tagged with
comments powered by Disqus