ERROR 1452: Cannot add or update a child row: a foreign key constraint fails

后端 未结 21 2013
野性不改
野性不改 2020-11-22 07:01

I have created tables in MySQL Workbench as shown below :

ORDRE table:

CREATE TABLE Ordre (
  OrdreID   INT NOT NULL,
  OrdreDato DA         


        
21条回答
  •  温柔的废话
    2020-11-22 07:35

    The Problem is with FOREIGN KEY Constraint. By Default (SET FOREIGN_KEY_CHECKS = 1). FOREIGN_KEY_CHECKS option specifies whether or not to check foreign key constraints for InnoDB tables. MySQL - SET FOREIGN_KEY_CHECKS

    We can set foreign key check as disable before running Query. Disable Foreign key.

    Execute one of these lines before running your query, then you can run your query successfully. :)

    1) For Session (recommended)

    SET FOREIGN_KEY_CHECKS=0;
    

    2) Globally

    SET GLOBAL FOREIGN_KEY_CHECKS=0;
    

提交回复
热议问题