用insert into tablename(fieldname1) values('') 再用select * from tablename where fieldname1 = ''这样是查不出刚刚插进去的数据的, 要用select * from tablename where fieldname1 is null ^_^
null 和 '' 是不一样的,也许高版本的ORACLE认为是一样的吧
null 和 '' 不一样,除非是字符型
SQL> select nvl('',0) from dual;N - 0SQL> select nvl(NULL,0) from dual;NVL(NULL,0) ----------- 0 有什么区别吗?
一直认为NULL和''是不一样的,最好是 where ...and (c1='' or c1 is null) and ......
if fieldname='' then ..和if fieldname=' ' then ..不一样,后者表示是个空格,前者表示是空;
在oracle中. null 不等于 null的.null也不等于''select * from table_test where 字段=null 将得不到任何数据., select * from table_test where 字段 is null <---正确.select * from table_test where 字段='' <--也得不到正确的结果
select * from table_test where 字段='' 这样不行的,得不到正确结果还是要使用is null
to dinya2003(OK) 如你所说 那我现在要求往表里插入值为 ''的记录,并且把值为 ''的记录select出来。。 '' 就是 NULL 但是不能这样查 where field='' 要写成 is null 的形式。。“select * from table_test where 字段=null 将得不到任何数据.,” ================================= 这是概念问题了,对于NULL值,oracle语法规定必须是 IS NULL来判断,而不是=NULL 写成=NULL当然不对了
select * from a where name is null
''就是 NULL
NULL 就是 ''判断
select name from table where name is NULL;
select name from table where name is NOT NULL;
里面 '' 和 NULL是一回事
在MySQL和SQL Server(也就是MSSQL)里面, ''和NULL不一样的
再用select * from tablename where fieldname1 = ''这样是查不出刚刚插进去的数据的,
要用select * from tablename where fieldname1 is null
^_^
-
0SQL> select nvl(NULL,0) from dual;NVL(NULL,0)
-----------
0
有什么区别吗?
where ...and (c1='' or c1 is null) and ......
select * from table_test where 字段 is null <---正确.select * from table_test where 字段='' <--也得不到正确的结果
这样不行的,得不到正确结果还是要使用is null
如你所说
那我现在要求往表里插入值为 ''的记录,并且把值为 ''的记录select出来。。 '' 就是 NULL
但是不能这样查 where field='' 要写成 is null 的形式。。“select * from table_test where 字段=null 将得不到任何数据.,”
=================================
这是概念问题了,对于NULL值,oracle语法规定必须是 IS NULL来判断,而不是=NULL
写成=NULL当然不对了