ORACLE判断空值? 这是我的一个面试题材

解决方案 »

  1.   

    select * from tb where col is null.
      

  2.   


    -- 为空: FIELD_NAME IS NULL
    -- 不为空: FIELD_NAME IS NOT NULL
    -- 相关的函数: NVL(FIELD_NAME,0)
      

  3.   

    is null or not null
      

  4.   

    where column_name is null ;
    where column_name is not null;
    nvl(,);
    nvl2(,,);
    上面两个是函数,请参考相关文档 
      

  5.   

     声明:菜鸟回答,老鸟勿笑。
      前几天上课 老师给讲了个例子 对于oracle 中的 emp 表  有个字段comm 是佣金字段 有的员工的 comm是0,有的就是null 如果要给一个员工 加佣金 null+数字  结果还是null 所有用了一个函数。
    nvl(comm+300,300)  {300 是增加的佣金数)  如果为comm字段 不为空 就返回:comm+300 ,如果为空就直接把 comm的值设为300。
      

  6.   

    把空值置为300
    update emp set comm=
    case
    when null
    then 300
    end;update emp set comm=300 where comm is null;
      

  7.   

    1、is null 为空;
    2、is not null 不为空;
    3、nvl(字段,值)为函数,如果字段为空则返回值,否则返回字段的值。
    4、‘’空格不是空值。