CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ

Table K(amt INT CHECK (amt > 0)) is empty. These run one at a time: INSERT (-5); INSERT (NULL); INSERT (0); INSERT (3). How many rows does K end up with?

  1. A. 2
  2. B. 1
  3. C. 3
  4. D. 0

Correct answer: A. 2

A CHECK constraint rejects a row only when the condition is FALSE. For NULL, amt > 0 is UNKNOWN, so the NULL row is accepted along with 3; -5 and 0 fail. Use NOT NULL as well to forbid the NULL.

More DBMS and SQL questions

Exams that ask this topic