Mysql workbench foreign key options [Restrict, Cascade, Set Null, No Action], what do they do?

user2310173 picture user2310173 · Apr 23, 2013 · Viewed 33.7k times · Source

In foreign key options on update and on delete. What does each field [Restrict, Cascade, Set Null, No Action] do?

Answer

Axel Agarrat picture Axel Agarrat · Apr 23, 2013

If you take one by one :

For both update and delete :

if you try to update / delete the parent row :

Restrict : Nothing gonna be delete if there is a child row

Cascade : the child row will be delete / update too

Set Null : the child column will be set to null if you delete the parent

No action : The child row will not be concern of the delete / update