在oracle中Null值既不等于Null,也不是不等于Null值。
观察一下三种情况
观察一下三种情况
第一种情况
SQL> select * from dual where null=null;
未选定行
SQL> select * from dual where null=null;
未选定行
第二种情况
SQL> select * from dual where null !=null;
未选定行
SQL> select * from dual where null !=null;
未选定行
第三种情况
SQL> select * from dual where null is null;
SQL> select * from dual where null is null;
D
-
X
-
X
实践1:
create table test1(id_num binary_float,id_name varchar2(10));
create table test1(id_num binary_float,id_name varchar2(10));
insert into test1(id_num,id_name) values(1,'a');
/
insert into test1(id_num,id_name) values(2,'b');
/
insert into test1(id_num,id_name) values(3,null);
/
insert into test1(id_num,id_name) values(4,null);
/
insert into test1(id_num,id_name) values(5,'c');
/
/
insert into test1(id_num,id_name) values(2,'b');
/
insert into test1(id_num,id_name) values(3,null);
/
insert into test1(id_num,id_name) values(4,null);
/
insert into test1(id_num,id_name) values(5,'c');
/
select * from test1 where id_name=null;--不返回结果
select * from test1 where id_name is null;--返回结果
如果在id_name建立索引,影响将更大,因为oracle的B*Tree不会检索空条目。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25786698/viewspace-696292/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25786698/viewspace-696292/