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

后端 未结 21 1999
野性不改
野性不改 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:51

    The problem occurs because you set the foreign key in child table after you insert some data in the child table.

    Try removing all the data from child table, then set the foreign key and afterwards add/insert the data in table, it will work.

提交回复
热议问题