Null Values

A null value is a placeholder that indicates the absence of a value. Null values exist for all data types. The null value of a given data type is different from all non-null values of the same data type.
idmscu
A null value is a placeholder that indicates the absence of a value. Null values exist for all data types. The null value of a given data type is different from all non-null values of the same data type.
By default, any column can contain null values. You can use either the NOT NULL or the CHECK parameter in a column definition to disallow null values in the column.
Parameters and local variable of SQL-invoked routines can always contain null values. However, it is possible to define initial values.
Host variables can also represent null values. You use an indicator variable with a host variable to indicate whether the host variable represents a null value.
How You Specify a Null Value
You use the keyword NULL to indicate a null value. For example, the following INSERT statement inserts a new row into the DEPARTMENT table. The department number and name and the division code are known, but the department head has not been appointed yet. A null value is used as a placeholder in the DEPT_HEAD_ID column.
insert into department    (dept_id, dept_name, div_code, dept_head_id)    values (4040, 'Audit', 'D09', null);
Null Values in Comparison and Arithmetic Operations
Null values have the following effect in comparison and arithmetic operations:
  • The result of a
    comparison operation
    involving one or more null values is always unknown
  • The result of an
    arithmetic operation
    involving one or more null values is always a null value
Null Values in Sort Operations
In a sort operation, a null value is a high value. Thus, a null is placed at the end of an ascending sort sequence.
More Information