Bird
0
0

Consider the domain:

medium📝 query result Q5 of 15
PostgreSQL - Advanced Features
Consider the domain:
CREATE DOMAIN positive_int AS integer CHECK (VALUE > 0);

What will be the result of inserting 0 into a column of type positive_int?
AInsertion fails due to type mismatch
BInsertion fails due to check constraint violation
CInsertion succeeds but stores NULL
DInsertion succeeds and stores 0
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the domain's check condition

    The domain requires VALUE > 0, so zero is not allowed.
  2. Step 2: Determine the effect of inserting 0

    Since 0 does not satisfy the check, the insertion will fail with a constraint violation.
  3. Final Answer:

    Insertion fails due to check constraint violation -> Option B
  4. Quick Check:

    Check VALUE > 0 rejects 0 = Insert fails [OK]
Quick Trick: Check constraints reject values outside allowed range [OK]
Common Mistakes:
  • Thinking 0 passes > 0 check
  • Confusing type mismatch with constraint failure
  • Assuming NULL is stored on failure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes