Subject | Nulls in CHECK Constraints |
---|---|
Author | paulruizendaal |
Post date | 2005-10-25T12:29:34Z |
I have come across an interesting difference between Oracle and
Firebird in the area of check constraints.
The Oracle website argues:
<quote>
When you are evaluating a WHERE clause, UNKNOWN leads to the same end
result as FALSEthe row is rejected. Yet in a CHECK constraint,
UNKNOWN leads to the same end result as TRUEthe row is accepted.
This is because constraints raise violations only if their Boolean
expressions evaluate to FALSE. It's why the following constraint
definition allows nulls in the DEPTNO column, although it might
suggest otherwise:
CHECK (DEPTNO IN (10, 20, 30))
Here is a good way to think about all this. The action of WHERE and
HAVING clauses is to pass those rows for which expressions evaluate
to TRUE. The action of a CHECK constraint is to reject rows for which
expressions are FALSE. In all cases, no action, neither pass nor
reject, is taken in the UNKNOWN case.
</quote>
What are the opinions about this? What does the standard say? What do
other databases implement?
Thanks,
Paul
Firebird in the area of check constraints.
The Oracle website argues:
<quote>
When you are evaluating a WHERE clause, UNKNOWN leads to the same end
result as FALSEthe row is rejected. Yet in a CHECK constraint,
UNKNOWN leads to the same end result as TRUEthe row is accepted.
This is because constraints raise violations only if their Boolean
expressions evaluate to FALSE. It's why the following constraint
definition allows nulls in the DEPTNO column, although it might
suggest otherwise:
CHECK (DEPTNO IN (10, 20, 30))
Here is a good way to think about all this. The action of WHERE and
HAVING clauses is to pass those rows for which expressions evaluate
to TRUE. The action of a CHECK constraint is to reject rows for which
expressions are FALSE. In all cases, no action, neither pass nor
reject, is taken in the UNKNOWN case.
</quote>
What are the opinions about this? What does the standard say? What do
other databases implement?
Thanks,
Paul