`

Cannot delete or update a parent row: a foreign key constraint fails的思考

 
阅读更多

1.假设Group实体对应着多个User实体


2.假设Group没有对userList设置级联删除


3.当删除Group实体对象则出错:

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails


4当删除Group实体对象时,需要先把Group下的所有User干掉,然后再把Group干掉


5.over

分享到:
评论

相关推荐

    MySQL删除表的时候忽略外键约束的简单实现

    ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails 这是因为你尝试删除的表中的字段被用作了其他表的外键,因此在删除这个表(父表)之前必须先删除具有外键的表(子表)...

    Navicat删除行时报Cannot delete or update a parent row: a foreign key constraint fails

    在SSM项目中执行一个删除用户操作时报错,遂在navicat中尝试是否可以直接删除,报如下所示错误 student表的主键是selectedcourse表的外键,当需要删除student表内的一行数据时,必须在selectedcourse表内设置该外键...

    解决django 新增加用户信息出现错误的问题

    (1452, 'Cannot add or update a child row: a foreign key constraint fails (`mxonline`.`django_admin_log`, CONSTRAINT `django_admin_log_user_id_c564eba6_fk_auth_user_id` FOREIGN KEY (`user_id`) ...

    MySQL添加外键时报错:1215 Cannot add the foreign key constraint的解决方法

    这篇文章主要涉及到在数据创建表时,遇到ERROR 1215 (HY000): Cannot add foreign key constraint 问题方面的内容,对于在数据创建表时,遇到同样问题感兴趣的同学可以参考一下。 一、问题的提出 创建两个表:  ...

    sql关闭与开启

    Cannot delete or update a parent row: a foreign key constraint fails (...) 这可能是MySQL在InnoDB中设置了foreign key关联,造成无法更新或删除数据。可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况。 SET ...

    MySQL删除有外键约束的表数据方法介绍

    aforeignkeyconstraintfails (...) 这是因为MySQL中设置了foreign key关联,造成无法更新或删除数据。可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况。 禁用外键约束,我们可以使用: SETFOREIGN_KEY_CHECKS=...

    INSERT语句与FOREIGN KEY约束冲突

    阅读此书以了解根本原因:SQL FOREIGN KEY Constraint [^]

    SSD7 选择题。Multiple-Choice

    The foreign key in a table T1 _____ the same _____ as the corresponding primary key in table T2. must have, name need not have, name must have, domain (a) I, II, and III (b) I and II (c) ...

    python-mysql day05.txt

    constraint 外键名 foreign key(字段) references 主表(字段) on delete 级联动作 on update 级联动作 3、级联动作 1、cascade :删除、更新同步(被参考字段) 2、restrict :不让主表更新、删除 3、set null...

    mysql外键(Foreign Key)介绍和创建外键的方法

    在MySQL中,InnoDB引擎类型的表支持了外键约束。外键的使用条件:1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但...外键的定义语法: 代码如下:[CONSTRAINT symbol] FOREIGN KEY [i

    Grammatical theory From transformational grammar to constraint-based approaches

    Grammatical theory From transformational grammar to constraint-based approaches Stefan Müller 2017新书,欢迎对形式语言学,自然语言处理等领域感兴趣读者下载。

    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘a3b6420a-6’ for key ‘callId’

    "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'a3b6420a-6724-11ea-b2a3-d773d1d6999f' for key 'callId'\nThe SQL being executed was: INSERT INTO `ly_call` (`call_id`, `mobile`, ...

    课程设计—仓库设备管理

    课程设计—仓库设备管理系统.doc 创建基本表的SQL代码: create table Equipment ( ...alter table Stock add constraint Eno3 foreign key(Eno) references Equipment(Eno) on update cascade on delete cascade

    电子线路图

    Processing Rule : Short-Circuit Constraint (Allowed=Not Allowed) (On the board ),(On the board ) Rule Violations :0 Processing Rule : Broken-Net Constraint ( (On the board ) ) Rule Violations :0 ...

    级联删除笔记【自用0分】

    foreign key(AID) references dbo.A(AID) on delete cascade on update cascade go alter table dbo.C add constraint FK_C_B_BID foreign key(BID) references dbo.B(BID) on delete cascade on update cascade go ...

    SQL SERVER 2000中的列级约束与表级约束

    SQL Server 2000中的列级约束与表级约束 在SQL Server 2000中有5 种约束: 主键约束(primary key constraint) 唯一性约束(unique constraint) 检查约束(check constraint...外部键约束(foreign key constraint)

    mysql数据库设计(1).pdf

    添加级联操作 语法:ALTER TABLE 表名 ADD CONSTRAINT 外键名称 FOREIGN KEY (外键字段名称) REFERENCES 主表名称(主表列名称) ON UPDATE CASCADE ON DELETE CASCADE ; 2. 分类: 1. 级联更新:ON UPDATE CASCADE 2...

    微软内部资料-SQL性能优化3

    For example, suppose a transaction scanned a page using an S lock and then subsequently decided to perform a row level update. The row would obtain an X lock, but now the page would require an IX ...

    Web Applications with Javascript or Java, Volume 1-De Gruyter(2018).pdf

    This two-volume book shows how to design and implement web applications with a model-based engineering approach, using the two most relevant technology plat- forms for web development: JavaScript and ...

Global site tag (gtag.js) - Google Analytics