Sobes.tech
Junior — Middle

What is the default behavior of an Oracle database when deleting a row that is linked to another through a foreign key?

sobes.tech AI

Answer from AI

By default, in Oracle, attempting to delete a row that is referenced by a foreign key in another table results in a constraint violation error (ORA-02292). This occurs because foreign keys are, by default, set with the RESTRICT behavior, which prohibits deleting a parent record if related child records exist.

To change this behavior, you can use the ON DELETE CASCADE option (automatically delete related records) or ON DELETE SET NULL (set foreign keys to NULL), but these options are not enabled by default.