gpt4 book ai didi

mysql - 错误: Can't create table 'Goober.Employee' (errno: 150)

转载 作者:行者123 更新时间:2023-11-29 21:44:33 24 4
gpt4 key购买 nike

出于某种原因,我收到以下错误,我知道它与我刚刚添加的“UsesTruck”外键有关,但是我不知道我做错了什么。我只包含了我认为的表格对于这个问题很重要。

CREATE TABLE Employee (
EmployeeID INT AUTO_INCREMENT,
Name VARCHAR(90) NOT NULL,
UsesTruck CHAR(20) NULL,
FOREIGN KEY (UsesTruck) REFERENCES Truck(LicensePlate),
PRIMARY KEY (EmployeeID));


CREATE TABLE Truck (
LicensePlate CHAR(20) NULL,
color VARCHAR(45) NULL,
capacity VARCHAR(45) NULL,
PRIMARY KEY (LicensePlate));
CREATE TABLE Shifts (
ShiftTime VARCHAR(15) NOT NULL,
PRIMARY KEY (ShiftTime));



CREATE TABLE Reservation (
ReservNum INT NOT NULL,
ReserveDate VARCHAR(45) NULL,
PickupTime VARCHAR(45) NOT NULL,
NumOfPassengers INT NULL,
sheduledTime VARCHAR(45) NULL,
ActualPickupTime VARCHAR(45),
ActualTime VARCHAR(45),
PricePaid VARCHAR(45),
DriverHourlyRate DECIMAL(7,2) NULL,
PassEmployeeHourlyRate DECIMAL (7,2) NULL,
DriverSalary VARCHAR(10),
PassEmployeeSalary VARCHAR(10),
Customer_CustomerID INT,
Truck_LicensePlate char(20) NULL,
Employee_EmployeeID_Driver INT,
Location_Address_Pickup VARCHAR(100),
Employee_EmployeeID_Passenger INT,
Location_Address_Drop VARCHAR(100),
PRIMARY KEY (ReservNum),
FOREIGN KEY (Customer_CustomerID) REFERENCES Customer (CustomerID),
FOREIGN KEY (Truck_LicensePlate) REFERENCES Truck (LicensePlate),
FOREIGN KEY (Employee_EmployeeID_Driver) REFERENCES Employee (EmployeeID),
FOREIGN KEY (Location_Address_Pickup) REFERENCES Location (Address),
FOREIGN KEY (Employee_EmployeeID_Passenger) REFERENCES Employee (EmployeeID),
FOREIGN KEY (Location_Address_Drop) REFERENCES Location (Address));

最佳答案

首先尝试运行创建卡车表。

关于mysql - 错误: Can't create table 'Goober.Employee' (errno: 150),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34207747/

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