我无法弄清楚这个错误:
Cannot add or update a child row: a foreign key constraint fails (
freight
.rates_detail
, CONSTRAINTrates_detail_ibfk_2
FOREIGN KEY (component_id
) REFERENCEScomputation
(id
) ON UPDATE CASCADE)
这是我正在尝试做的(来自日志):
INSERT INTO freight.rates_detail(rate_id,component_id,uom,rate,inc_or) values(0821,01,00,011.00,'Y')
我反复查看和查看表 computation
中 id
的值以及该情况下的值:01 存在。
这有什么问题?
最佳答案
i just found out that the reference table is
MyISAM
notInnoDB
will it affect?
是的。如 Using FOREIGN KEY
Constraints 下所述:
The parent and child tables must use the same storage engine.
接着说:
For storage engines that do not support foreign keys (such as
MyISAM
), MySQL Server parses and ignores foreign key specifications.
关于MySQL 外键约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18829616/