Both OnDelete and OnUpdate have the Restrict, NoAction, Cascade, and SetNull attributes. Now let's explain the meaning of their properties separately. ONDELETErestrict: when deleting the corresponding record in the parent table (that is, the source table of the foreign key), first check that the record is On Delete and On Update both have Restrict, No Action, cascade, Set Null attribute. Now let's explain the meaning of their properties separately.
ON DELETE
Restrict): When deleting a corresponding record in the parent table (that is, the source table of the foreign key), first check whether the record has a corresponding foreign key. If yes, deletion is not allowed.
No action:The same as restrict. that is, if the slave data exists, the master data cannot be deleted.
Cascade ):When deleting a corresponding record in the parent table (that is, the source table of the foreign key), first check whether the record has a corresponding foreign key, if any, the records of foreign keys in the sub-table (that is, the table containing foreign keys) are also deleted.
Set null:When deleting a corresponding record in the parent table (that is, the source table of the foreign key), first check whether the record has a corresponding foreign key, if yes, set the foreign key value in the subtable to null (however, this requires that the foreign key be allowed to be null)
ON UPDATE
Restrict): When updating the corresponding record in the parent table (that is, the source table of the foreign key), first check whether the record has the corresponding foreign key. If yes, update is not allowed.
No action:The same as restrict.
Cascade ):When updating the corresponding record in the parent table (that is, the source table of the foreign key), first check whether the record has the corresponding foreign key, if any, the record of the foreign key in the sub-table (that is, the table containing the foreign key) is also updated.
Set null:When updating the corresponding record in the parent table (that is, the source table of the foreign key), first check whether the record has the corresponding foreign key, if yes, set the foreign key value in the subtable to null (however, this requires that the foreign key be allowed to be null ).
Note: the difference between "no action" and "RESTRICT" is that the operation is executed after the ACTION with other constraints, and that of "no action" has the highest priority.