大家好,又见面了,我是你们的朋友全栈君
oracle之优化is null语句
一:is null的优化
方法:通过nvl(字段,j)=j的方式,将字段中为空的数据转化为j,从而正常使用索引。...当然还有另外一种方式解决这个问题:将null包含到索引中
–使用nvl函数的方式(不用添加索引,推荐)
select * from student t where 1=nvl(t.age,1);
–当t.age...decode(age,null,1));
select * from student t where decode(t.age,null,1)=1;
二:is not null的优化
方法:结果集不包含...1 form student s where 1=nvl(s.age,1));
–11g版本后not in和not exists趋于相似,也可以用not in
–当t.col_x不存在等于1的数据时等价于...1
–当t.age为总是小于1的数值时
select * from student t where 1>nvl(t.age,1);
–直接比较大小,暗含了 IS NOT NULL
select * from