Bird
0
0

You defined a foreign key with ON UPDATE SET NULL but when you update the parent key, the child foreign key does not become NULL. What is a possible reason?

medium📝 Debug Q7 of 15
SQL - Table Constraints
You defined a foreign key with ON UPDATE SET NULL but when you update the parent key, the child foreign key does not become NULL. What is a possible reason?
AThe parent key update was not committed.
BON UPDATE SET NULL only works with ON DELETE CASCADE.
CThe child foreign key column is defined as NOT NULL.
DThe foreign key constraint was not created.
Step-by-Step Solution
Solution:
  1. Step 1: Check child foreign key column nullability

    If the child foreign key column is NOT NULL, it cannot be set to NULL on update.
  2. Step 2: Understand effect on ON UPDATE SET NULL

    ON UPDATE SET NULL fails silently or rejects update if child column disallows NULL.
  3. Final Answer:

    The child foreign key column is defined as NOT NULL. -> Option C
  4. Quick Check:

    NOT NULL child column blocks SET NULL update [OK]
Quick Trick: Child column NOT NULL blocks SET NULL update [OK]
Common Mistakes:
MISTAKES
  • Thinking ON UPDATE SET NULL requires ON DELETE CASCADE
  • Assuming update not committed causes issue
  • Believing constraint was not created

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes