Bird
0
0

Which ON DELETE action will set the foreign key column in child rows to NULL when the parent row is deleted?

easy📝 Conceptual Q2 of 15
SQL - Table Constraints
Which ON DELETE action will set the foreign key column in child rows to NULL when the parent row is deleted?
AON DELETE CASCADE
BON DELETE RESTRICT
CON DELETE SET NULL
DON DELETE NO ACTION
Step-by-Step Solution
Solution:
  1. Step 1: Recall ON DELETE SET NULL effect

    This option sets the foreign key column in child rows to NULL when the parent row is deleted.
  2. Step 2: Compare with other options

    CASCADE deletes child rows, RESTRICT blocks delete, NO ACTION behaves like RESTRICT in many systems.
  3. Final Answer:

    ON DELETE SET NULL sets child foreign keys to NULL on parent delete. -> Option C
  4. Quick Check:

    ON DELETE SET NULL = Set foreign key to NULL [OK]
Quick Trick: SET NULL clears foreign keys on parent delete [OK]
Common Mistakes:
MISTAKES
  • Confusing CASCADE with SET NULL
  • Assuming RESTRICT sets NULL
  • Thinking NO ACTION deletes child rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes