Bird
0
0

Which of the following is the correct syntax to create a domain named positive_int that only allows positive integers?

easy📝 Syntax Q12 of 15
PostgreSQL - Advanced Features
Which of the following is the correct syntax to create a domain named positive_int that only allows positive integers?
ACREATE DOMAIN positive_int AS integer CHECK (VALUE > 0);
BCREATE DOMAIN positive_int TYPE integer WHERE VALUE > 0;
CCREATE DOMAIN positive_int AS integer VALIDATE (VALUE > 0);
DCREATE DOMAIN positive_int AS integer IF VALUE > 0;
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct syntax for domain creation

    The syntax is: CREATE DOMAIN name AS base_type CHECK (condition);
  2. Step 2: Match the syntax with options

    CREATE DOMAIN positive_int AS integer CHECK (VALUE > 0); matches the correct syntax with CHECK and VALUE keyword.
  3. Final Answer:

    CREATE DOMAIN positive_int AS integer CHECK (VALUE > 0); -> Option A
  4. Quick Check:

    CREATE DOMAIN ... AS ... CHECK(...) [OK]
Quick Trick: Use CHECK with VALUE keyword in domain creation [OK]
Common Mistakes:
  • Using TYPE instead of AS
  • Using WHERE or VALIDATE instead of CHECK
  • Missing parentheses around condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes