【发布时间】:2023-03-12 04:45:02
【问题描述】:
尝试以下代码:
create table donation(
donation_number int not null primary key ,
product_id int not null
);
create table stock (
product_id int not null primary key,
available_qty int not null,
FOREIGN KEY (product_id ) REFERENCES donation(product_id)
);
回馈
错误代码:1822。添加外键约束失败。引用表“捐赠”中缺少约束“stock_ibfk_1”的索引。
为什么?我该如何解决这个问题?
【问题讨论】:
-
在引用的表“捐赠”中缺少索引 ..。 - 此消息中有什么不清楚的地方?
标签: mysql sql foreign-keys