Mega Code Archive

 
Categories / Oracle PLSQL / Select Query
 

= NULL or is NULL

SQL> SQL> CREATE TABLE DEPT (DEPTNO NUMBER(2),DNAME VARCHAR2(14),LOC VARCHAR2(13) ); Table created. SQL> SQL> INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK'); 1 row created. SQL> INSERT INTO DEPT VALUES (20, 'RESEARCH', 'DALLAS'); 1 row created. SQL> INSERT INTO DEPT VALUES (30, 'SALES', 'CHICAGO'); 1 row created. SQL> INSERT INTO DEPT VALUES (40, 'OPERATIONS', 'BOSTON'); 1 row created. SQL> SQL> insert into dept ( deptno, dname, loc ) values ( 50, 'IT', NULL ); 1 row created. SQL> SQL> SQL> select * from dept where loc = NULL; no rows selected SQL> select * from dept where loc IS NULL;     DEPTNO DNAME          LOC ---------- -------------- -------------         50 IT SQL> select * from dept where loc IS NOT NULL;     DEPTNO DNAME          LOC ---------- -------------- -------------         10 ACCOUNTING     NEW YORK         20 RESEARCH       DALLAS         30 SALES          CHICAGO         40 OPERATIONS     BOSTON 4 rows selected. SQL> SQL> drop table dept; Table dropped. SQL>