我正在使用phpMyAdmin.为了使用InnoDB设置外键约束(在Structure选项卡上的“Relation View”链接下),我似乎需要为要添加约束的字段添加索引.这显然会影响表上插入/更新的性能,特别是如果我想添加几个约束.是否可以在InnoDB中指定外键约束或关系完整性而无需为所需字段创建索引?
非常感谢
JS,伦敦
解决方法:
InnoDB requires indexes on foreign
keys and referenced keys so that
foreign key checks can be fast and not
require a table scan. In the
referencing table, there must be an
index where the foreign key columns
are listed as the first columns in the
same order. Such an index is created
on the referencing table automatically
if it does not exist. (This is in
contrast to some older versions, in
which indexes had to be created
explicitly or the creation of foreign
key constraints would fail.)
标签:mysql,foreign-keys,innodb
来源: https://codeday.me/bug/20190726/1547298.html