Search code examples
sqloracleforeign-keys

What is Oracle's default FK behaviour ON DELETE?


If I simply stipulate a constraint of the form:

ALTER TABLE childtbl
    ADD (CONSTRAINT myfk
         FOREIGN KEY(mycol)
         REFERENCES parenttbl(mycol))

in an Oracle database, what is the default behaviour if I delete a row in parenttbl?

  • CASCADE?
  • SET NULL?
  • RESTRICT?
  • NO ACTION?

Solution

  • ON DELETE NO ACTION

    Disallows the update or deletion of referenced data. This differs from RESTRICT in that it is checked at the end of the statement, or at the end of the transaction if the constraint is deferred. (Oracle Database uses No Action as its default action.)