[英]MySQL Foreign Key Constraint
I can't figure out this error: 我无法弄清楚这个错误:
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)不能添加或更新子行,外键约束失败(
freight
。rates_detail
,约束rates_detail_ibfk_2
外键(component_id
)参考computation
(id
)ON UPDATE CASCADE)
Here's what I'm trying to do(from the log): 这是我想要做的(从日志中):
INSERT INTO freight.rates_detail(rate_id,component_id,uom,rate,inc_or) values(0821,01,00,011.00,'Y')
I repeatedly looked and looked and reviewed the values of id
in table computation
and the value in that case: 01 exists. 我反复查看并查看了表
computation
的id
值,在这种情况下,值:01存在。
What's the problem with this? 这是什么问题?
i just found out that the reference table is
MyISAM
notInnoDB
will it affect?我只是发现引用表是
MyISAM
而不是InnoDB
会影响吗?
Yes. 是。 As documented under Using
FOREIGN KEY
Constraints : 如使用外
FOREIGN KEY
约束中所述 :
The parent and child tables must use the same storage engine.
父表和子表必须使用相同的存储引擎。
It goes on to say: 它继续说:
For storage engines that do not support foreign keys (such as
MyISAM
), MySQL Server parses and ignores foreign key specifications.对于不支持外键的存储引擎(例如
MyISAM
),MySQL Server会解析并忽略外键规范。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.