oralce 中的一个表有个字段varchar2类型的,值为'123456'
然后我用<>''查不出,用is not nul就可以。
这是为什么?

解决方案 »

  1.   

    is not null/is null
    是oracle 的标准写法
      

  2.   

    null 表示什么都没有, '123456' 既存在...'' 是存在的,值为空
      

  3.   

    ‘’不是空,在数据存储上是占一个位置的。而null是不分配空间的。
      

  4.   

    那么为什么<>''查不出来?
      

  5.   

    其实''和null都是空。
    不同的地方是表达式可以用 is (not) null的写法,但是不能用is ''的写法。
    SQL> select 1 from dual where '' is null;         1
    ----------
             1
    SQL> select 1 from dual where ''='';no rows selected
      

  6.   

    ''与NULL是有区别的NULL表示什么都没有''表示有东西,它的值为空格null需要用 is,不能用=''则用=
      

  7.   

    null是一个特殊的类型不等于空,具体查查相关的资料
      

  8.   

    对sql语句的执行上好像并没有差别:SQL> create table zzw_temp1(id number,comm varchar2(10));表已创建。SQL> insert into zzw_temp1 values(1,'');已创建 1 行。SQL> insert into zzw_temp1 values(1,null);已创建 1 行。SQL> insert into zzw_temp1 values(12,'happy');已创建 1 行。SQL> select *from zzw_temp1;        ID COMM
    ---------- ----------
             1
             1
            12 happySQL> select *from zzw_temp1 where comm is null;        ID COMM
    ---------- ----------
             1
             1SQL> select *from zzw_temp1 where comm is not null;        ID COMM
    ---------- ----------
            12 happy
      

  9.   

    '' 相当于null,语句变成 <> null;当然没记录了,此时要用标准写法 is not null;如果想判断你要的空,用 <>' ' --两个引号中间有一位的空格,这代表有字符,有内容。
      

  10.   

    与null比较都要用is  
    <>'' , <> null 比较结果都是false的
      

  11.   

    ‘’不是空,在数据存储上是占一个位置的。而null是不分配空间的。