Bird
0
0

A developer tries: ALTER TABLE employees ADD CONSTRAINT unique_email UNIQUE email; but gets an error. What is wrong?

medium📝 Debug Q7 of 15
SQL - Table Constraints
A developer tries: ALTER TABLE employees ADD CONSTRAINT unique_email UNIQUE email; but gets an error. What is wrong?
AUNIQUE constraints cannot be added with ALTER TABLE
BMissing parentheses around column name in UNIQUE constraint
CColumn email does not exist in employees table
DUNIQUE constraint requires NOT NULL on the column
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax for adding UNIQUE constraint

    The column name must be inside parentheses after UNIQUE keyword.
  2. Step 2: Identify syntax error

    Missing parentheses causes syntax error in the statement.
  3. Final Answer:

    Missing parentheses around column name in UNIQUE constraint -> Option B
  4. Quick Check:

    Parentheses required for column list in constraints [OK]
Quick Trick: Always use parentheses around columns in constraints [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses in ALTER TABLE ADD CONSTRAINT
  • Assuming UNIQUE can't be added later
  • Confusing column existence with syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes