我不能創建表Item_CopyERROR 1005(HY000):無法創建表「Item_Copy」(錯誤:150)無法創建表Item_Copy
CREATE TABLE Library
(
Library_ID int primary key,
Library_Address varchar(40),
Library_Phone bigint
);
CREATE TABLE Branch
(
Library_ID int,
Branch_Number int,
Branch_Name varchar(40),
Branch_Address varchar(40),
Branch_Phone bigint,
Branch_Hours varchar(40),
primary key (Library_ID,Branch_Number),
foreign key (Library_ID) references Library(Library_ID)
);
CREATE TABLE Item_Copy
(
Item_ID int primary key,
Copy_Number int,
Copy_Condition varchar(40),
Copy_Date_Acquired date,
Copy_Cost int,
Library_ID int,
Branch_Number int,
foreign key (Library_ID) references Branch(Library_ID),
foreign key (Branch_Number) references Branch(Branch_Number),
foreign key (Item_ID) references Item(Item_ID)
);
只用ITEM_ID再次嘗試。如果可行,請刪除它並添加下一個字段。重複,直到找到導致錯誤的行。 –
沒有涵蓋'分支(Branch_Number)'字段的索引。該問題也缺少「Item」表定義。 – zerkms