OnDelete (Foreign Key Keyword)
Usage
To specify what happens in the current table when a referenced record is deleted in the foreign table, use the following syntax:
ForeignKey keyname(key_props) References pkg.class(ref_index) [ OnDelete = ondelete ];
Where ondelete is one of the following:
-
noaction (default) — When an attempt is made to delete a referenced record in the foreign table, the attempt fails.
-
cascade — When a referenced record is deleted in the foreign table, the referencing record in this table is also deleted.
-
setdefault — When a referenced record is deleted in the foreign table, the reference to the foreign table in the referencing record is set to its default value.
-
setnull — When a referenced record is deleted in the foreign table, the reference to the foreign table in the referencing record is set to null.
Description
When a row is deleted in the foreign table, all referencing tables with a foreign key constraint on the foreign table are checked to see if any row references the row being deleted. If any such references are found, the OnDelete action takes effect.
Default
The default is noaction.
See Also
-
Defining a Foreign Key in the InterSystems SQL Reference