Oracle两个易错的地方,关于null和''的逻辑比较

1.在Varchar2的格式中‘’相当于null(都不分配内存)。

select '存在' aa from dual where '' is null


这句话的结果是存在的。

2.在Oracle中不能对null做逻辑判断,只能使用is和is not。

select '存在' aa from dual where null = null;
select '存在' aa from dual where null <> null;
select '存在' aa from dual where 'aa' <> null;
select '存在' aa from dual where 'aa' <> '';

这四句话的结果都是不存在的(注意第三、四句话);

select '存在' aa from dual where null is null;
select '存在' aa from dual where 'aa' is not null;


这两句话的结果是存在的;




原文地址:https://www.cnblogs.com/javawebsoa/p/3089423.html