现在的位置: 首页 > 综合 > 正文

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

2013年09月17日 ⁄ 综合 ⁄ 共 365字 ⁄ 字号 评论关闭

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;

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

抱歉!评论已关闭.