gpt4 book ai didi

mysql - 错误代码 : 3175. 无法在基列具有外部约束的虚拟列上创建索引

转载 作者:行者123 更新时间:2023-11-29 20:16:39 25 4
gpt4 key购买 nike

在 MySQL 5.7.11 中,添加其中一列是虚拟生成列的复合索引会导致以下错误:

Error Code: 3175. Cannot create index on virtual column whose base column has foreign constraint

实际上,生成虚拟列的基列没有任何外部约束,因此错误消息令人费解。

MySQL 5.7.15 中不会出现该错误。

最佳答案

错误信息是错误的。实际问题是索引中的其他两列定义了外键,这些外键被设置为更新级联。 MySQL 5.7.14 之前不允许这样做:

In MySQL 5.7.13 and earlier, InnoDB does not permit defining cascading referential actions on non-virtual foreign key columns that are explicitly included in a virtual index. This restriction is lifted in MySQL 5.7.14. (source)

将 key 更改为更新限制可使错误消失。这也解释了为什么在MySQL 5.7.15中不会出现这个错误。

关于mysql - 错误代码 : 3175. 无法在基列具有外部约束的虚拟列上创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39729333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com