Does Oracle support ON UPDATE CASCADE in foreign keys?

Difficulty: Easy

Correct Answer: Valid (Oracle does not support ON UPDATE CASCADE; only ON DELETE CASCADE is available)

Explanation:


Introduction / Context:
Different relational databases offer different referential actions. Oracle historically supports ON DELETE CASCADE but does not implement ON UPDATE CASCADE in declarative foreign keys. Knowing this prevents designing schemas that rely on unsupported automatic key updates.


Given Data / Assumptions:

  • We are defining a foreign key in Oracle.
  • We want to understand available referential actions.
  • Application may need to change parent key values (not recommended practice).


Concept / Approach:
Oracle encourages stable primary keys. When parent key values must change, you typically perform controlled updates using application logic or surrogate keys, or you recreate related rows. Declaratively, Oracle allows ON DELETE CASCADE and ON DELETE SET NULL/DEFAULT (as applicable), but not ON UPDATE CASCADE. Therefore, the statement that Oracle does not support CASCADE UPDATE is correct.


Step-by-Step Solution:

Attempt to define a foreign key with ON UPDATE CASCADE — Oracle raises a syntax error.Define supported actions, such as ON DELETE CASCADE, successfully.If updates to keys are needed, implement them via code or redesign to avoid updating keys.Prefer surrogate immutable keys to avoid the need for key updates.


Verification / Alternative check:
Consult Oracle reference for CREATE TABLE … FOREIGN KEY constraints; ON UPDATE options are absent. Testing in SQL*Plus confirms unsupported syntax.


Why Other Options Are Wrong:

  • Edition, deferrability, or MERGE does not introduce ON UPDATE CASCADE support.


Common Pitfalls:
Porting schemas from MySQL or PostgreSQL that rely on ON UPDATE CASCADE; forgetting to protect parent key stability.


Final Answer:
Valid (Oracle does not support ON UPDATE CASCADE; only ON DELETE CASCADE is available)

More Questions from Managing Databases with Oracle

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion