A column is declared CHECK (price > 0). What happens when a row is inserted with price set to NULL?
Correct answer
D. The row is accepted, because a null check result counts as unknown
23 views
D. The row is accepted, because a null check result counts as unknown
23 views
A CHECK constraint rejects a row only when the predicate evaluates to false; NULL yields unknown, which is treated as satisfied. To forbid both non-positive and missing values you must add NOT NULL explicitly. This is the same three-valued logic that makes NOT IN against a subquery containing a NULL return no rows at all.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is D? Ask here and get an explanation.