What happens to the insert?
CREATE TABLE line ( qty INT CHECK (qty > 0) ); INSERT INTO line VALUES (NULL);
- It stores 1, the minimum
- It stores 0 in place of NULL
- It succeeds and stores NULL
- It fails the
CHECKrule
A
Play SQL & Databases ▸
CHECK only rejects rows where the condition is false; NULL > 0 is unknown, so it passes. Add NOT NULL to forbid it.