Background documentationDELETE Rule (delete_rule) Locate this document in the navigation structure

 

The DELETE rule (delete_rule) defines the effects that deleting a row in the referenced table (referenced_table) has on the referencing table.

Structure

Syntax Syntax

  1. <delete_rule> ::=
      ON DELETE CASCADE
    | ON DELETE RESTRICT
    | ON DELETE DEFAULT
    | ON DELETE SET NULL
End of the code.
Explanation
  • No DELETE rule: Deleting a row in the referenced table will fail if matching rows exist.

  • ON DELETE CASCADE: If a row in the referenced table is deleted, all of the matching rows are deleted.

  • ON DELETE RESTRICT: Deleting a row in the referenced table fails if matching rows exist.

  • ON DELETE SET DEFAULT: If a row in the referenced table is deleted, the associated DEFAULT value is assigned to each matching row of each referencing column. A DEFAULT specification must exist for each referencing column.

  • ON DELETE SET NULL: If a row in the referenced table is deleted, a NULL value is assigned to each referencing_column of each matching row. None of these referencing columns may be a NOT NULL column.