浅谈oracle 空值null与'null',''
2013-10-23 15:42
337 查看
oracle的null,'null',''值在具体到写sql语句的时候,经常会产生疑虑,不知道是写成null还是'null'还是'',写的是否正确,因此实践了一下,解决自己在以后的顾虑。
1.字段与空值的比较:
select t.name from emps_table t where t.name <> 'null'
上述sql语句不能写为:
select t.name from emps_table t where t.name <> null
否则结果和自己想要的不一样
2.集合与空值的比较:
测试sql:
1. 假如select t.name from emps_table t where t.name <> '' 返回一个空集合
2. 测试集合与null的比较
select decode((select t.name from emps_table t where t.name <> ''),null,'1','2') from dual
结果输出:1 ,说明空集合==null
select decode((select t.name from emps_table t where t.name <> ''),‘null’,'1','2') from dual
结果输出:2,说明空集合!='null‘
3.其实,'null'==''
select t.name from emps_table t where t.name <> 'null'
select t.name from emps_table t where t.name <> ''
结果是一样的。
1.字段与空值的比较:
select t.name from emps_table t where t.name <> 'null'
上述sql语句不能写为:
select t.name from emps_table t where t.name <> null
否则结果和自己想要的不一样
2.集合与空值的比较:
测试sql:
1. 假如select t.name from emps_table t where t.name <> '' 返回一个空集合
2. 测试集合与null的比较
select decode((select t.name from emps_table t where t.name <> ''),null,'1','2') from dual
结果输出:1 ,说明空集合==null
select decode((select t.name from emps_table t where t.name <> ''),‘null’,'1','2') from dual
结果输出:2,说明空集合!='null‘
3.其实,'null'==''
select t.name from emps_table t where t.name <> 'null'
select t.name from emps_table t where t.name <> ''
结果是一样的。
相关文章推荐
- Oracle 和 SQL Server 在处理 NULL 和空值之间的差异
- oracle之简null空值问题,用nvl(a,b)函数解决
- oracle、sqlserver数据库排序空值null问题解决办法
- 浅谈JAVA中的空值与null的判断
- oracle空值null的漫谈
- oracle、sqlserver数据库排序空值null问题解决办法
- oracle空值查询 为null的column;
- oracle、sqlserver数据库排序空值null问题解决办法
- oracle中的空值null
- oracle 空值与 null
- Oracle 和 SQL Server 在处理 NULL 和空值之间的差异
- oracle、sqlserver数据库排序空值null问题解决办法
- Oracle空值(null)运算陷阱
- 关于空值null的排序问题 mysql 和oracle
- Oracle-空值null和数字相加的问题-nvl函数
- oracle null 和空字符串
- oracle约束总结(not null/unique/primary key/foreign key/check)
- Oracle空串与null的处理
- MySQL 中NULL和空值的区别
- oracle null 和 空串 ''