marvelyu
作者marvelyu·2013-11-05 15:59
软件开发工程师·IBM

关于null和’‘字符串的测试

字数 5065阅读 1201评论 0赞 0
今天突然遇见过类似的如下问题,经过测试,发现原来null和空值其实还是有区别的,改天在整理下:
create table tab
( id    integer not null,
  name  char(50),
  empid  char(10),
  salary  char(15)
);

insert into tab values(1,'JACK','0001','2000');

insert into tab values(2,'TOM','0002','');

insert into tab values(3,'LUCY','0003','3000');

insert into tab values(4,'JAME','0004','');

insert into tab values(4,'KIM','0005',null);


db2 => select * from tab;
select * from tab

ID          NAME                                               EMPID      SALARY
----------- -------------------------------------------------- ---------- ---------------
          1 JACK                                               0001       2000
          2 TOM                                                0002
          3 LUCY                                               0003       3000
          4 JAME                                               0004
          4 KIM                                                0005       -

  5 record(s) selected.

db2 => select * from tab where salary not in ('2000','3000');
select * from tab where salary not in ('2000','3000')

ID          NAME                                               EMPID      SALARY
----------- -------------------------------------------------- ---------- ---------------
          2 TOM                                                0002
          4 JAME                                               0004

  2 record(s) selected.

db2 => select * from tab where salary is null;
select * from tab where salary is null

ID          NAME                                               EMPID      SALARY
----------- -------------------------------------------------- ---------- ---------------
          4 KIM                                                0005       -

  1 record(s) selected.

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广