gpt4 book ai didi

MySQL - 区分大小写 : Cannot add or update a child row: a foreign key constraint fails

转载 作者:行者123 更新时间:2023-11-29 21:50:24 26 4
gpt4 key购买 nike

我有一个表Customer,其外键约束为CustomerType(CustomerTypeId)

现在使用 EntityFramework,当我尝试在 Customer 表中插入记录时,出现错误消息

Cannot add or update a child row: a foreign key constraint fails ("Event"."Customer", CONSTRAINT "customer_ibfk_2" FOREIGN KEY ("CustomerTypeId") REFERENCES "CustomerType" ("CustomerTypeId"))

在研究此错误时,我发现在 MySQL 数据库中它区分大小写,因此我收到此错误。

是否有任何可能的解决方案来忽略 MYSQL 中的大小写敏感度?

最佳答案

一种解决方案是在任何地方使用lower函数。另一种解决方案更好,您必须修复数据库。更改您的外键或表,或者重新创建表。如果您有很多记录,则必须首先停用外键,然后根据需要更改值,然后再次激活外键。试试这个

关于MySQL - 区分大小写 : Cannot add or update a child row: a foreign key constraint fails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33705767/

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