I always thought that a NULL string is NULL. When I inserted a NULL String, I could use NULL. However, some time ago, I found that the NULL Character Set was not included after I used the not in value, at that time, I also thought that it should be included. Then I did the following test and found that NULL and NULL strings in DB2 are not the same thing.
Create table tab
(Id integer not null,
Name char (50 ),
Empid char (10 ),
Salary char (15)
);
Insert into tab values (1, 'jack', '123', '123 ');
Insert into tab values (2, 'Tom ', '123 ','');
Insert into tab values (3, 'Lucy ', '20160301', '20160301 ');
Insert into tab values (4, 'jame', '2013 ','');
Insert into tab values (4, 'Kim ', '20140901', null );
Db2 => select * from tab;
Select * from tab
ID NAME EMPID SALARY
--------------------------------------------------------------------------------------
1 JACK 0001 2000
Two TOM 0002
3 LUCY 0003 3000
4. JAME 0004
4. KIM 0005-
5 record (s) selected.
Db2 => select * from tab where salary not in ('20140901', '20160901 ');
Select * from tab where salary not in ('20140901', '20160901 ')
ID NAME EMPID SALARY
--------------------------------------------------------------------------------------
Two 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
The answer to this DB2 document is that NULL is an uncertain value and can represent any value. Therefore, it is not included in any specified set and the NULL value cannot be filtered by column values, it can only be filtered by the is null or is not null method, so you can see the result above. This seems to be different from Oracle, so different databases are still different and cannot be applied directly, perform more hands-on tests to learn the truth.
Recommended reading:
DB2 database performance adjustment and optimization (1st and 2) PDF
DB2 database performance optimization