The NULL keyword specifies the null value. When assigned to a
column of any data type, the NULL keyword forces the column to
be set to null because the NULL keyword has no data type. For
example:
SQL> -- List all employees in the database and all potential employees
SQL> --
SQL> SELECT employee_id, last_name, first_name
cont> FROM employees
cont> UNION
cont> SELECT NULL, last_name, first_name
cont> FROM candidates;
.
.
.
00418 Blount Peter
00435 MacDonald Johanna
00471 Herbener James
NULL Boswick Fred
NULL Schwartz Trixie
NULL Wilson Oscar
103 rows selected
The NULL keyword is distinct from the IS NULL predicate which
tests for null values of an expression. When testing an
expression for null, using equality with NULL (for example, a
predicate when testing an expression as shown in the following
example:
SQL> SELECT e.last_name, j.job_end
cont> FROM employees e, job_history j
cont> WHERE e.employee_id = j.employee_id
cont> AND j.job_end IS NULL;
E.LAST_NAME J.JOB_END
Smith NULL
O'Sullivan NULL
Hastings NULL
.
.
.
In some cases, the NULL keyword may have a data type of CHAR(31)
when used in a query that requires a data type; such as in
arithmetic and character expressions. In such queries, the
assumption of the CHAR data type may cause an incompatibility
error. If this occurs, use the CAST function (for example, CAST
(NULL AS data-type)) to change NULL to a compatible data type for
the query.