Bird
0
0

Which of the following is the correct syntax to add a UNIQUE constraint to an existing column email in a table users?

easy📝 Syntax Q12 of 15
SQL - Table Constraints
Which of the following is the correct syntax to add a UNIQUE constraint to an existing column email in a table users?
AALTER TABLE users ADD UNIQUE email;
BALTER TABLE users ADD CONSTRAINT UNIQUE email;
CALTER TABLE users ADD UNIQUE (email);
DALTER TABLE users ADD UNIQUE CONSTRAINT (email);
Step-by-Step Solution
Solution:
  1. Step 1: Recall ALTER TABLE syntax for UNIQUE and check options

    The correct syntax to add a UNIQUE constraint is: ALTER TABLE table_name ADD UNIQUE (column_name); "ALTER TABLE users ADD UNIQUE (email);" matches exactly. The other options misuse keywords or omit parentheses.
  2. Final Answer:

    ALTER TABLE users ADD UNIQUE (email); -> Option C
  3. Quick Check:

    ALTER TABLE ADD UNIQUE (column) syntax = ALTER TABLE users ADD UNIQUE (email); [OK]
Quick Trick: Use ADD UNIQUE (column) with parentheses [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around column name
  • Using ADD CONSTRAINT UNIQUE without naming constraint
  • Misplacing keywords in ALTER TABLE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes