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

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

    You are getting this constraint check because Ordre table does not have reference OrdreID provided in insert command.

    To insert value in Ordrelinje, you first have to enter value in Ordre table and use same OrdreID in Orderlinje table.

    Or you can remove not null constraint and insert a NULL value in it.

提交回复
热议问题