oracle中null与‘’(空字符串)的问题

--oracle 中 null 与空字符串的问题

create table students(

   student_id number primary key,

   student_name varchar2(20),

   student_age number,

   student_desc varchar2(600)--200个汉字

)

--表中数据


 --更新

update students s set s.student_name = null where s.student_id = '1';

update students s set s.student_name = '' where s.student_id = '2';

--查询

select * from students;



select * from students s where s.student_name is null;  的结果为:

而select * from students s where s.student_name = '';这种是始终无结果的。

可以看出将student_name设置成null与空字符串('')的效果一样,也是就说在oracle中空字段(即没有数据的字段)是用null标识的。当设置字段为空字符串时,在oracle数据库中会当成null处理

 

 

猜你喜欢

转载自weigang-gao.iteye.com/blog/2075377