what is the default on delete and on update [duplicate]
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
精彩评论