Search notes:

SQL: null values

The SQL standard defines a special null value for every data type.
This implies that it is impossible to determine the data type of a null value.
The null value is specifically used for unknown data and indicates that either the correct value for a data-item is unknown or not applicaple.
Because the value is unknown, it implies that null is neither equal nor different to any other value, including another null value: Any standard operator comparisons (=, <> etc.) with null values are false.
This gives raise to a three-valued logic. (Rule number 3 of Codd's twelve rules).
In order to check for null values, the special is null operator is needed.
The null value might be denoted by the keyword null.
Although a null value is different from every other null value, in a group by aggregation, they form one group.
SQL Standard feature F383 specifies a set column not null clause which, if used, prohibits inserting a null value into that column.

Two possible interpretations of null

Although the SQL standard explicitly defines null as unknown, we find that there are at least two possible interpretations of a null value when encountering it. In addition to viewing a null value as unknown, it can also be regarded as none.
For example, if we don't know the street number of a customer's address, we insert null into the respective field. However, there are addresses that don't have a street number. So, we also insert null.
In such a case, it's impossible to tell unknown from none, and additional flags are required in a table.
Because null can be interpreted differently, we consider null values a major challenge for Data preparation.

Misc

Oracle considers the empty string to be null. (See also Oracle SQL: null).

See also

The expression coalesce(p1, p2, … pₙ) evaluates to the first parameter (pₓ) that is not null.
The expression nullif(p1, p2) evaluates to null if p1 == p2, otherwise to p1.
The .NET class System.DBNull is .NET's way to represent a non-existing value.
The VBA null value
null in SQL Server
Python has the value None to indicate absence of a value.
Feature E131 of the SQL standard

Index