- 在order 中,简单把null认为是最大
- 与null的运算,返回null
SQL> select 1 + null from dual;
1+NULL
----------
- 与null的字符串合并,忽略null
SQL> select 'Hi'||null from dual;
'HI'||NULL
----------
Hi
- Null的查询为is null
- Count(field),不包括null
- 如果索引条目全为null,则索引不记录null
- In/not in与null
- Exists/not exists与null
SQL> select * from t1;
A B
---------- ----------
1 1
2
3
SQL> select * from t2;
A B
---------- ----------
1 1
2
SQL> select * from t1 where b in (select B from t2);
A B
---------- ----------
1 1
SQL> select * from t1 where b not in (select B from t2);
A B
---------- ----------
SQL> select * from t1 where exists (select * from t2 where t2.b = t1.b);
A B
---------- ----------
1 1
SQL> select * from t1 where not exists (select * from t2 where t2.b = t1.b);
A B
---------- ----------
3
2
exists主要用于片面的,有满足一个条件的即可, 所以速度快很多. in 主要用于具体的集合操作, 有多少满足条件.