Bird
0
0

What will happen if you name two different constraints on the same table with the same name?

medium📝 query result Q5 of 15
SQL - Table Constraints
What will happen if you name two different constraints on the same table with the same name?
ABoth constraints will work without issues
BThe second constraint will overwrite the first one silently
CThe database will rename the second constraint automatically
DThe database will return an error due to duplicate constraint names
Step-by-Step Solution
Solution:
  1. Step 1: Understand uniqueness requirement for constraint names

    Constraint names must be unique within the same schema or table to avoid confusion.
  2. Step 2: Identify database behavior on duplicate names

    Most databases throw an error if you try to create a constraint with a duplicate name.
  3. Final Answer:

    The database will return an error due to duplicate constraint names -> Option D
  4. Quick Check:

    Duplicate constraint names cause error = C [OK]
Quick Trick: Constraint names must be unique per table/schema [OK]
Common Mistakes:
MISTAKES
  • Assuming silent overwrite
  • Thinking auto rename happens
  • Believing duplicates are allowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes