MySQL ON UPDATE RESTRICT 有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8371950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does ON UPDATE RESTRICT do?
提问by Alex
...
user_id INTEGER NOT NULL,
CONSTRAINT fk_user_meta FOREIGN KEY (user_id)
REFERENCES users (id) ON DELETE CASCADE ON UPDATE RESTRICT
I know from herethat ON DELETE CASCADE means that if I delete a row from the users table, then the associated row from the user meta table will be removed too. But what does ON UPDATE RESTRICT do?
我从这里知道 ON DELETE CASCADE 意味着如果我从用户表中删除一行,那么用户元表中的关联行也将被删除。但是 ON UPDATE RESTRICT 有什么作用呢?
回答by Chris Eberle
RESTRICT
prevents the action from happening if there's any foreign keys that rely on the field that's being changed.
RESTRICT
如果有任何依赖正在更改的字段的外键,则阻止操作发生。