其实''和null都是空。 不同的地方是表达式可以用 is (not) null的写法,但是不能用is ''的写法。 SQL> select 1 from dual where '' is null; 1 ---------- 1 SQL> select 1 from dual where ''='';no rows selected
对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
'' 相当于null,语句变成 <> null;当然没记录了,此时要用标准写法 is not null;如果想判断你要的空,用 <>' ' --两个引号中间有一位的空格,这代表有字符,有内容。
是oracle 的标准写法
不同的地方是表达式可以用 is (not) null的写法,但是不能用is ''的写法。
SQL> select 1 from dual where '' is null; 1
----------
1
SQL> select 1 from dual where ''='';no rows selected
---------- ----------
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
<>'' , <> null 比较结果都是false的