以下脚本会产生错误:
CREATE TABLE BOTTLE
(
Bottle_ID VARCHAR(30) NOT NULL,
BottleSize NUMBER(10,0) ,
Shape VARCHAR(30) ,
GlassColor VARCHAR(30) ,
BottleInventory NUMBER(10,0) ,
CostPerBottle NUMBER(5,2) ,
constraint BOTTLE_PK PRIMARY KEY (Bottle_ID)
);
create table BOTTLE_VENDOR
(
Vendor_ID VARCHAR(30) not null,
VendorName VARCHAR(20),
Vendor_Straddr1 VARCHAR(100),
Vendor_Straddr2 VARCHAR(100),
Vendor_City VARCHAR(20),
Vendor_State VARCHAR(20),
Vendor_Zip CHAR(5),
Vendor_Phone VARCHAR(20),
PrincipalContact VARCHAR(30),
constraint pk_BOTTLE_VENDOR primary key (Vendor_ID)
);
create table BOTTLE_ORDER
(
Bottle_Order_ID VARCHAR(30) not null,
BottleOrderDate DATE,
Vendor_ID VARCHAR(30),
constraint pk_BOTTLE_ORDER primary key (Bottle_Order_ID),
constraint fk_BOTTLE_ORDER foreign key (Vendor_ID) references BOTTLE_VENDOR(Vendor_ID)
);
create table SHIPMENT
(
Shipment_ID VARCHAR(30) not null,
ShipmentDate DATE,
ReceivedQuantity INTEGER,
ReceivedDate DATE,
Bottle_Order_ID VARCHAR(30),
constraint pk_SHIPMENT primary key (Shipment_ID),
constraint fk_SHIPMENT foreign key (Bottle_Order_ID) references BOTTLE_ORDER(Bottle_Order_ID)
);
create table BOTTLE_ORDER_LINE
(
Bottle_Order_ID VARCHAR(30) not null,
Bottle_ID VARCHAR(30) not null,
BottleOrderQuantity INTEGER,
ActualPricePerBottle NUMBER(5,2),
constraint pk_BOTTLE_ORDER_LINE primary key (Bottle_Order_ID,Bottle_ID),
constraint fk_BOTTLE_ORDER_LINE foreign key (Bottle_Order_ID) references BOTTLE_ORDER(Bottle_Order_ID),
constraint fk_BOTTLE_ORDER_LINE2 foreign key (Bottle_Order_ID) references BOTTLE(Bottle_ID)
);
这是完全显示的内容:
错误从第37行开始:命令中约束 - 约束fk_SHIPMENT外键(Bottle_Order_ID)引用BOTTLE_ORDER(Bottle_Order_ID)
错误报告 -
未知命令
错误让我发疯,并且不知道如何处理它。
答案 0 :(得分:0)
以下行(您发布的最后一行)与您的表定义不符:
constraint fk_BOTTLE_ORDER_LINE2 foreign key (Bottle_Order_ID) references BOTTLE(Bottle_ID)
应该是:
constraint fk_BOTTLE_ORDER_LINE2 foreign key (Bottle_ID) references BOTTLE(Bottle_ID)