oracle null 和 空串 ''
来源:互联网 发布:西安软件公寓 编辑:程序博客网 时间:2024/05/16 13:01
**********************nvl
Oracle中的空字符串基本上是被当成空NULL来处理的
selectnvl('','NULL') from dual 返回'NULL'
select 1 from dual where '' is null 返回1。
如果我们在往数据表里插数据的时候,把某个值赋成空串(''),而查询条件加入了诸如col_x= ''等条件的话,结果是无法查出来的。
反过来,在使用||连接符时,NULL值又被当作空串来使用。
select null || 'ce'|| null ||'shi' from dual将返回串’ceshi’。
然而,空串''与空值NULL还是有些区别的
select 1 from dualwhere '' = null; 返回0行
select 1 from dualwhere null = ''; 返回0行
select 1 from dualwhere '' is null; 返回1行 结果为:1
select 1 from dualwhere null is ''; 报错缺失null关键字
declare a varchar(10);
b varchar(10);
c varchar(10);
begin
a := '';
b := null;
c := a;
dbms_output.put_line(a);
dbms_output.put_line(b);
if (a is null) then
dbms_output.put_line('yes') ;
else dbms_output.put_line('no') ;
end if;
if (b is null) then
dbms_output.put_line('yes') ;
else dbms_output.put_line('no') ;
end if;
if (c is null) then
dbms_output.put_line('yes') ;
else dbms_output.put_line('no') ;
end if;
-- if (nvl(a,'@') = nvl(c,'@')) then
if (a = c) then
dbms_output.put_line('yes') ;
else dbms_output.put_line('no') ;
end if;
dbms_output.put_line(c) ;
end;
结果为:yes yes yes no
“if (a = c) then”=替换为< 或> 结果不变
注释处替换后为yes yes yes yes
也就是说因为oracle认为空串就是null 所以赋值后,abc都是null但是由于null不参与任何=,<,> 运算。所以都是no。想做比较必须处理。(nvl只是其中一种)
- oracle null 和 空串 ''
- oracle null和空字符串
- Oracle 空字符串和NULL
- oracle 空字符'' 和Null
- oracle null 和空字符串
- oracle 的 null 和 空字符串('')
- oracle中的空和null区别
- Oracle中的NULL和空字符串
- oracle 的 null 和 空字符串('')
- Oracle中的NULL和空字符串
- oracle 的 null 和 空字符串('')
- oracle之空值(NULL)和空值函数使用
- Oracle空串与null的处理
- Oracle中的空串与NULL
- oracle中null和空字符串的区别
- oracle varchar2类型字段中的空字符串和null
- 关于空值null的排序问题 mysql 和oracle
- Java空串和null串
- input输入框将全角输入的数字转换为半角
- 11、Libgdx的音频
- ConcurrentHashMap 并发哈希映射
- Openstack Keystone 认证流程(三)-WSGI
- ViewPager实现淘宝天面首页广告栏,支持左右滑动,自动滑动,带圆点指示器
- oracle null 和 空串 ''
- MongoDB学习(三):MongoDB Shell的使用
- 【转载】Java之美[从菜鸟到高手演变]之设计模式
- VS2012打开VS2010项目报错
- MongoDB学习 (四):创建、读取、更新、删除(CRUD)快速入门
- 入学考试
- openGL es2.0 创建和管理shader
- SQL update select语句及应用
- reids客户端 redis-cli用法