MySQL 写入或更新时重复密钥?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20512572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:39:14  来源:igfitidea点击:

Duplicate key on write or update?

mysqlsql

提问by

Duplicate key on write or update

写入或更新时重复密钥

First i will like to acknowledge the fact that, i have been to similar posts, but i couldn't find a way to solve this annoying issue which i face as of present.I am using mysql workbenchand i keep getting this error.

首先,我要承认这样一个事实,我去过类似的帖子,但我找不到解决目前面临的烦人问题的方法。我正在使用mysql 工作台,但不断收到此错误。

  1. On workbench :ERROR: Error 1005: Can't create table 'database.path' (errno: 121)

  2. Use "Perror 121" on command line :MySQL error code 121: Duplicate key on write or update

  1. 在工作台上:错误:错误 1005:无法创建表“database.path”(错误号:121)

  2. 在命令行上使用“Perror 121”:MySQL 错误代码 121:写入或更新时出现重复键

At the end of the log, it shows 9 successful operationsand 1 failurewith only pathtable visible in the logs.

在日志的末尾,它显示了9 次成功操作1 次失败,并且日志中只有路径表可见。

Any help and suggestion is welcomed.I think the mysql compiler doesn't really do a good Job when it comes to signifying the actual issue for debugging.

欢迎提供任何帮助和建议。我认为 mysql 编译器在表示调试的实际问题方面做得并不好。

回答by

Sorry guys, i found the problem. It is related to this post.

对不起各位,我发现了问题。它与这篇文章有关。

Which was hinted by rakeshjain.

这是由rakeshjain暗示的

It may be deleted as a duplicate post by admin.

它可能会被管理员删除为重复的帖子。

The answer is, i had two CONTRAINTS on different tables with the same name:

答案是,我在不同的表上有两个同名的 CONTRAINTS:

CONSTRAINT Update_ID_fk--> Changed one and problem solved.

CONSTRAINT Update_ID_fk--> 换了一个,问题解决了。

回答by Vahap Gencdal

Your Foreign key names must be unique

您的外键名称必须是唯一的