Bird
0
0

Which of the following is the correct syntax to add a CHECK constraint named chk_salary on the salary column to ensure it is positive during table creation?

easy📝 Syntax Q3 of 15
SQL - Table Constraints
Which of the following is the correct syntax to add a CHECK constraint named chk_salary on the salary column to ensure it is positive during table creation?
Asalary INT CONSTRAINT chk_salary CHECK (salary > 0)
BCONSTRAINT chk_salary salary INT CHECK (salary > 0)
Csalary INT CHECK (salary > 0) CONSTRAINT chk_salary
Dsalary INT CHECK chk_salary (salary > 0)
Step-by-Step Solution
Solution:
  1. Step 1: Recall syntax for named CHECK constraints on columns

    The correct order is: column definition, then CONSTRAINT name, then CHECK condition.
  2. Step 2: Match options with correct syntax

    salary INT CONSTRAINT chk_salary CHECK (salary > 0) matches the correct syntax: salary INT CONSTRAINT chk_salary CHECK (salary > 0).
  3. Final Answer:

    salary INT CONSTRAINT chk_salary CHECK (salary > 0) -> Option A
  4. Quick Check:

    CONSTRAINT name comes before CHECK condition [OK]
Quick Trick: CONSTRAINT name goes before CHECK condition in column defs [OK]
Common Mistakes:
MISTAKES
  • Placing CONSTRAINT after CHECK
  • Putting CONSTRAINT before column type
  • Using CHECK without parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes