Was this helpful?
Nulls and Integrities
If you create an integrity involving a column that is nullable (has been created using the WITH NULLS clause so the user can insert a NULL), the condition must take into consideration the possibility of encountering a null value. For more information on nullable columns, see the chapter “Managing Tables and Views.” For example, suppose the number column in a particular table is nullable, and you define an integrity with the following condition that restricts number values to 50 or less:
number <= 50
Null is not in itself a value, so the comparison evaluates to false for any row in which the number column already has a null entry. You must create this integrity on a nullable column before the column contains any nulls. Otherwise, the integrity is rejected. Furthermore, with this integrity defined, the number column, even though it is defined as nullable, does not allow nulls.
To to allow nulls in the column, you need to define the integrity with a NULL clause to ensure proper handling of nulls with the integrity constraints:
number <= 50 or number is null
Last modified date: 08/14/2024