开发者

what is the default on delete and on update [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

开发者_如何学运维 What is MySQL's default ON DELETE behavior?

Hi all just want to know what the on delete and on update are set to on a foreign key if you dont specify what they are on a MYSQL database. I've been searching and cant really find out the answer. Like if I just create a foreign key what are they set too. Thanks.


the default action is RESTRICT.

via http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html


As stated in the MySQL docs:

If ON DELETE or ON UPDATE are not specified, the default action is RESTRICT. 

http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html


The default is to disallow any update or delete of a parent row if it would orphan one or more child rows.

In this case the error looks like this:

ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜