gpt4 book ai didi

mysql - mysql 递归关系更新级联

转载 作者:行者123 更新时间:2023-11-29 14:57:39 24 4
gpt4 key购买 nike

create table employee(emp_id int primary key ,emp_name char(9),
spouse_id int,foreign key(spouse_id)references employee (emp_id)
on delete cascade set null on update cascade);

friend 们大家好

当我删除数据时,它会对相关数据产生影响。但是当我尝试更新它时,它给出错误无法更改父数据。请帮我找到解决方案。

最佳答案

删除级联

on delete set null 

但是关于编辑..它在我的示例中工作正常..

也许这可以帮助你从Mysql引用:

Deviation from SQL standards: If ON UPDATE CASCADE or ON UPDATE SET NULL recurses to update the same table it has previously updated during the cascade, it acts like RESTRICT. This means that you cannot use self-referential ON UPDATE CASCADE or ON UPDATE SET NULL operations. This is to prevent infinite loops resulting from cascaded updates. A self-referential ON DELETE SET NULL, on the other hand, is possible, as is a self-referential ON DELETE CASCADE. Cascading operations may not be nested more than 15 levels deep.

关于mysql - mysql 递归关系更新级联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4166898/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com