0
点赞
收藏
分享

微信扫一扫

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


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

create table students(
   student_id number primary key,
   student_name varchar2(20),
   student_age number,
   student_desc varchar2(600)--200个汉字
)

--表中数据

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


 --更新

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;

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


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

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

 

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

 

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

 

 

举报

相关推荐

0 条评论