Exact Meaning of MySQL's Foreign Key 'on delete restrict' Clause

后端 未结 2 531
孤独总比滥情好
孤独总比滥情好 2020-12-28 11:36

I have two MySQL tables: collections and privacy_level.
I define them with a foreign key relationship as such:



        
2条回答
  •  时光说笑
    2020-12-28 12:23

    ON DELETE RESTRICT means you can't delete a given parent row if a child row exists that references the value for that parent row. If the parent row has no referencing child rows, then you can delete that parent row.

    ON DELETE RESTRICT is pretty much superfluous syntax, because this is the default behavior for a foreign key anyway.

提交回复
热议问题