gpt4 book ai didi

MySql - 无法添加或更新子外键约束失败

转载 作者:行者123 更新时间:2023-11-29 06:25:09 25 4
gpt4 key购买 nike

<分区>

我有两个表,“booking”和“isBooked”。我想向 isBooked 表添加值。但我不断收到错误消息“无法添加或更新子外键约束失败”。

CREATE TABLE booking (
bookingID INT AUTO_INCREMENT,
customerID INT,
startDate DATE,
endDate DATE,
dateBookedOn TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
employeeID int,
PRIMARY KEY (bookingID),
INDEX idx_start (startDate),
INDEX idx_end (endDate),
FOREIGN KEY (customerID) REFERENCES customer(CustomerID)
);

CREATE TABLE isBooked(
BookingID int,
DogID int,
RunID int,
foreign key (RunID) references Run(RunID),
foreign key (DogID) references Dog(dogID),
foreign key (BookingID) references Booking(BookingID)
);


insert into isbooked values(1, 1, 1);

谁能告诉我为什么在尝试向“isBooked”插入值时出现此错误。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com