MYSQL ERROR 1005(HY000):无法创建表

时间:2022-06-01 18:47:46

I get this error and I have no idea why this is my first time using MYSQL and I can't seem to find a solution that works anywhere.

我收到此错误,我不知道为什么这是我第一次使用MYSQL,我似乎无法找到适用于任何地方的解决方案。

CREATE TABLE Orders ( 
 ordID INT NOT NULL AUTO_INCREMENT, 
 sellName VARCHAR(255) NOT NULL, 
 itemPrice REAL NOT NULL, 
 ordItems VARCHAR(255) NOT NULL, 
 ordQuantity INT NULL, 
 CONSTRAINT pk_order PRIMARY KEY (ordID), 
 CONSTRAINT fk_ord_sell FOREIGN KEY (sellName) REFERENCES Seller 
(sellName), 
 CONSTRAINT fk_ord_item FOREIGN KEY (itemPrice) REFERENCES Item 
(itemPrice) 
) ENGINE = InnoDB;

1 个解决方案

#1


0  

I think your problem is with the foreign keys....because i do this:

我认为你的问题是外键....因为我这样做:

 CREATE TABLE Orders ( 
 ordID INT NOT NULL AUTO_INCREMENT, 
 sellName VARCHAR(255) NOT NULL, 
 itemPrice REAL NOT NULL, 
 ordItems VARCHAR(255) NOT NULL, 
 ordQuantity INT NULL, 
 CONSTRAINT pk_order PRIMARY KEY (ordID)
 ) ENGINE = InnoDB;

An let me create the table in a perfect way.

让我以完美的方式创造桌子。

Saludos.

#1


0  

I think your problem is with the foreign keys....because i do this:

我认为你的问题是外键....因为我这样做:

 CREATE TABLE Orders ( 
 ordID INT NOT NULL AUTO_INCREMENT, 
 sellName VARCHAR(255) NOT NULL, 
 itemPrice REAL NOT NULL, 
 ordItems VARCHAR(255) NOT NULL, 
 ordQuantity INT NULL, 
 CONSTRAINT pk_order PRIMARY KEY (ordID)
 ) ENGINE = InnoDB;

An let me create the table in a perfect way.

让我以完美的方式创造桌子。

Saludos.