This may be because MySQL has set foreign Key association in InnoDB, which makes it impossible to update or delete data. You can avoid this situation by setting the FOREIGN_KEY_CHECKS variable.
SET FOREIGN_KEY_CHECKS = 0;
SET
SET FOREIGN_KEY_CHECKS = 1;
SET FOREIGN_KEY_CHECKS = 0;
SET
SET FOREIGN_KEY_CHECKS = 1;
ERROR 1452 (23000): Cannot add or update a Child row: a foreign key constraint fails…… (foreign key restrictions cannot be inserted)
can also use (SET FOREIGN_KEY_CHECKS = 0; ) insert
Read More:
- Mysql error when deleting the table structure: Error Code: 1217. Cannot delete or update a parent row: a foreign key constraint fails
- Mysql error 1452 – Cannot add or update a child row: a foreign key constraint fails
- MySQL error code 1217 (ER_ROW_IS_REFERENCED): Cannot delete or update a parent row: a foreign key co
- MySQL failed to add foreign key: SQL 1452 cannot add or update a child row:a foreign key constraint fails
- Solution to error 1452: cannot add or update a child row: a foreign key constraint failures in MySQL
- MySql ERROR CODE:1215 Cannot add the foreign key constraint
- MySQL:Foreign key fails with error Error Code: 1452.
- Failed to add the foreign key constraint. Missing index for constraint ‘stu_ibfk_1’ in the reference
- 1822 – Failed to add the foreign key constraint. Missing index for constraint ‘tb_emp_ibfk_1’ in the
- MySQL error 1451 23000 foreign key exception handling
- Matlab delete row or col to delete the row or column of the matrix
- Ora-02292: integrity constraint (XX) violated – child record found foreign key Association, record cannot be deleted
- MySQL failed to add foreign key error 1452
- Flutter solves the problem of incorrect use of parent datawidget and boundary constraint
- MySQL: if the remote connection using navicatip fails, prompt “is not allowed to connect to this MySQL server”
- About MySQL error: subquery returns more than 1 row
- mysql Error Code: 1022. Can’t write; duplicate key in table `xxx`
- JPA transaction problems executing an update / delete query
- mysql5.7.26:[ERR] 1118 – Row size too large (> 8126)
- Insert into / delete / update / select of SQL Server database table