Oracle 检查列值是否为null

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Oracle 检查数据库列值是否为null


方法一、IS NULL

expr1 IS [NOT] NULL

SELECT *
  FROM emp t
WHERE t.comm IS NULL;

不知道为什么当 用Case expr1 is null then 0 这种方法来对列值为null的值处理的时候,总是有一部分 null 不会做处理。

方法二、NVL(expr1, expr2) 函数

如果expr1 为null,将会用expr2替代。

If expr1 contains a NULL value, then return expr3. If the value of expr1 contains a non-NULL
value, then return expr2.

Examples:
NVL2(‘A’,’B’,’C’) results in B
NVL2(NULL,’B’,’C’) results in C
NVL2(1,2,3) results in 2
NVL2(NULL,2,3) results in 3

转载于:https://my.oschina.net/u/2308739/blog/690331

你可能感兴趣的:(Oracle 检查列值是否为null)