I'm trying to make a FK on a column, and now I'm thinking when exactly should I use ON DELETE RESTRICT
? (or ON UPDATE RESTRICT
). Isn't it the same as NO ACTION
?
Well 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. Well its definition is the default behavior for a foreign key anyway.
Am I missing something?
They're equivalent. It even says so right there in the documentation:
NO ACTION
: A keyword from standard SQL. In MySQL, equivalent toRESTRICT
.
There's a difference between them in databases that have deferred checks, but MySQL doesn't.