简体   繁体   English

MySQL错误代码1062与1022之间的差异

[英]Difference for MySQL Error Code 1062 verses 1022

Review of MySQL error codes has me confused about the difference between 1022 and 1062 (see https://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html ). 查阅MySQL错误代码使我对1022和1062之间的区别感到困惑(请参阅https://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html )。 I currently don't have access to a test MySQL DB to investigate further. 我目前无法访问测试MySQL数据库以进行进一步调查。

So, what is the difference between MySQL error code 1022 and 1062 (they both say dup key)? 那么,MySQL错误代码1022和1062(它们都说dup键)之间有什么区别?

What gets raised for an attempted insert of an existing Primary Key? 尝试插入现有主键会引发什么?

What gets raised for an attempted insert of an existing Unique Key that is not a Primary Key? 尝试插入不是主键的现有唯一键会引起什么?

Differences between 1062 and 1022 error codes: 1062和1022错误代码之间的区别:

  • 1062 - is when you attempt to insert a row which results in a duplicated entry, it doesn't matter which type of key (primary, unique, etc). 1062-当您尝试插入导致重复条目的行时,无论哪种类型的键(主键,唯一键等)都无关紧要。
  • 1022 - seems to be used for a different purpose, for example, you can get it when creating a table with a duplicated key. 1022-似乎用于其他目的,例如,在创建具有重复键的表时可以获取它。

MySQL reference: MySQL参考:

Error: 1022 SQLSTATE: 23000 (ER_DUP_KEY)
Message: Can't write; duplicate key in table '%s'
Error: 1062 SQLSTATE: 23000 (ER_DUP_ENTRY)
Message: Duplicate entry '%s' for key %d

MySQL NET constants: MySQL NET常数:

MySqlErrorCode.DuplicateKey = 1022;
MySqlErrorCode.DuplicateKeyEntry = 1062;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM