Bird
0
0

Which of the following is the correct syntax to define a foreign key with ON UPDATE RESTRICT in SQL?

easy📝 Syntax Q3 of 15
SQL - Table Constraints
Which of the following is the correct syntax to define a foreign key with ON UPDATE RESTRICT in SQL?
AFOREIGN KEY (child_id) REFERENCES parent(id) ON DELETE CASCADE
BFOREIGN KEY (child_id) REFERENCES parent(id) ON UPDATE CASCADE
CFOREIGN KEY (child_id) REFERENCES parent(id) ON DELETE RESTRICT
DFOREIGN KEY (child_id) REFERENCES parent(id) ON UPDATE RESTRICT
Step-by-Step Solution
Solution:
  1. Step 1: Identify ON UPDATE RESTRICT syntax

    The correct syntax uses ON UPDATE RESTRICT after the REFERENCES clause.
  2. Step 2: Check options for correct placement

    FOREIGN KEY (child_id) REFERENCES parent(id) ON UPDATE RESTRICT correctly places ON UPDATE RESTRICT after the foreign key reference.
  3. Final Answer:

    FOREIGN KEY (child_id) REFERENCES parent(id) ON UPDATE RESTRICT -> Option D
  4. Quick Check:

    ON UPDATE RESTRICT syntax = FOREIGN KEY (child_id) REFERENCES parent(id) ON UPDATE RESTRICT [OK]
Quick Trick: ON UPDATE RESTRICT follows REFERENCES clause [OK]
Common Mistakes:
MISTAKES
  • Confusing ON UPDATE with ON DELETE
  • Placing ON UPDATE before REFERENCES
  • Using CASCADE instead of RESTRICT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes