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

后端 未结 3 1764
生来不讨喜
生来不讨喜 2021-02-01 05:08

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

3条回答
  •  没有蜡笔的小新
    2021-02-01 05:41

    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

提交回复
热议问题