Bird
0
0

You attempt to add a UNIQUE constraint on the email column in the subscribers table but receive an error. What is the most probable reason?

medium📝 Debug Q6 of 15
SQL - Table Constraints
You attempt to add a UNIQUE constraint on the email column in the subscribers table but receive an error. What is the most probable reason?
AThe table already has a PRIMARY KEY constraint.
BThe <code>email</code> column is not indexed.
CThe <code>email</code> column allows NULL values.
DThere are duplicate email values already present in the table.
Step-by-Step Solution
Solution:
  1. Step 1: Understand UNIQUE constraint addition

    Adding a UNIQUE constraint requires all existing values in the column to be unique.
  2. Step 2: Analyze error cause

    If duplicates exist, the constraint cannot be added, causing an error.
  3. Step 3: Evaluate options

    There are duplicate email values already present in the table. correctly identifies the cause. The email column is not indexed. is irrelevant since indexing is automatic or not required before adding UNIQUE. The email column allows NULL values. is usually allowed as UNIQUE permits multiple NULLs. The table already has a PRIMARY KEY constraint. is unrelated.
  4. Final Answer:

    There are duplicate email values already present in the table. -> Option D
  5. Quick Check:

    Duplicates block UNIQUE constraint addition [OK]
Quick Trick: Duplicates prevent adding UNIQUE constraint [OK]
Common Mistakes:
MISTAKES
  • Assuming NULLs cause errors
  • Thinking indexing is required before UNIQUE
  • Confusing PRIMARY KEY with UNIQUE constraints

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes