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;

這兩句話的結果是存在的;




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章