Bird
0
0

You try to create a table with:

medium📝 Debug Q6 of 15
SQL - Table Constraints
You try to create a table with:
CREATE TABLE test (id INT, CONSTRAINT chk_id CHECK id > 0);

But get a syntax error. What is the likely cause?
AMissing parentheses around the CHECK condition.
BCHECK constraints cannot be named.
CCONSTRAINT keyword is not allowed in table creation.
DThe condition must be written as a string.
Step-by-Step Solution
Solution:
  1. Step 1: Review syntax for table-level CHECK constraints

    Table-level CHECK constraints require the condition inside parentheses.
  2. Step 2: Identify missing parentheses

    The condition 'id > 0' is missing parentheses, causing syntax error.
  3. Final Answer:

    Missing parentheses around the CHECK condition. -> Option A
  4. Quick Check:

    CHECK condition must be in parentheses [OK]
Quick Trick: Always wrap CHECK condition in parentheses [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around condition
  • Thinking CONSTRAINT keyword is invalid
  • Writing condition as a string literal

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes