第15行的错误1452(23000):无法添加或更新子行: 外键约束失败(
cjcarey
。products
,CONSTRAINTproducts_ibfk_2
外键(sName
)参考suppliers
(suppliersname
)
-添加产品信息
insert into Products values(1, 'Bike', 3, 200.00, 'Vehicle', 'Walmart', 180.00, 5, '2017-12-09');
insert into Product values(2, 'Couch', 12, 450.00, 'Household', 'Homegoods', 300.00, 3, '2018-05-14');
-添加供应商信息
insert into Suppliers values('Walmart', '329 Carver Rd');
insert into Suppliers values('Homegoods', '4561 Parks Dr');
insert into Suppliers values('Hyvee', '2349 Morril St');
insert into Suppliers values('Lowes', '8828 WallyWorld Ave');
供应商表:
create table Suppliers(
SuppliersName varchar(255) not null,
address varchar(255),
primary key (SuppliersName)
);
产品表:
create table Products(
itemID int not null,
ProductName varchar(255),
RemainingQTY int,
Price float,
ProdType varchar(255) not null,
sName varchar(255) not null,
PurchasePrice float,
QTY int,
DateOfPurchase date,
primary key (itemID),
foreign key (ProdType) references ProductTypes(TypeName),
foreign key (sName) references Suppliers(SuppliersName)
);
我不确定该错误是什么意思吗?我想我正确引用了外键。