phpMyAdmin 错误 #1062 - 重复条目 '1'对于钥匙 1
我不确定为什么会收到此错误 #1062 - 键 1 的重复条目“1”,任何人都可以帮助解释它的含义。 谢谢
I am not sure why I am getting this error #1062 - Duplicate entry '1' for key 1 cany any one help explain what it means.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的列很可能被设置为“唯一”,并且您尝试输入的行的 ID 已存在于表中。
More than likely your column is set to be Unique, and you're trying to input a row with an ID that already exists in your table.
您可能正在尝试插入设置了 ID(或其他字段)
1
的记录,而表中已存在这样的记录。作为主键的字段对于每条记录都必须具有唯一的值。You are probably trying to insert a record with the ID (or some other field)
1
set, while such a record already exists in the table. The field that is the primary key must have a unique value for each record.我认为您正在尝试将“1”插入到已经具有“1”值的唯一关键字段中
I think you're trying to insert '1' to a unique key field that already has a '1' value
问题与您的文件有关 - 您正在尝试使用副本创建数据库 - 在文件顶部您会发现类似以下内容:
CREATE DATABASE IF NOT EXISTS
*THE_NAME_OF_YOUR_DB*
默认字符集 latin1 COLLATE latin1_general_ci;使用
*THE_NAME_OF_YOUR_DB*
;,我确信您已经有一个具有此名称的数据库 - 在同一服务器中 - 请检查。
The problem is related with your file - you are trying to create a DB using a copy - at the top of your file you will find something like this:
CREATE DATABASE IF NOT EXISTS
*THE_NAME_OF_YOUR_DB*
DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci;USE
*THE_NAME_OF_YOUR_DB*
;and I'm sure that you already have a DB with this name - IN THE SAME SERVER - please check.
您需要将主键添加到组中,其中一个主键必须是唯一值。
例如,如果一个表有 4 列 id、名称、地址、group_id,其中 group_id 具有重复值,如果我想将 group_id 添加为主,那么它应该位于包含 id 和 group_id 的组中
You need to add primary key with the group in which one primary key must be unique value.
e.g. if a table has 4 columns id, name, address, group_id where group_id has duplicate value , if I want to add group_id as primary then that should be in a group consist with id and group_id