#1062-密钥"PRIMARY"的重复条目 [英] #1062 - Duplicate entry for key 'PRIMARY'
问题描述
所以我的MySQL数据库表现得有些奇怪.这是我的桌子:
So my MySQL database is behaving a little bit wierd. This is my table:
Name shares id price indvprc
cat 2 4 81 0
goog 4 4 20 20
fb 4 9 20 20
当我尝试插入表中时出现此#1062错误.因此,我进一步研究了它,并意识到当我尝试在名称和共享值相同的表中插入值时,它将返回#1062错误.例如,如果我插入:
I'm getting this #1062 error when I try to insert into the table. So I looked into it further and realized that when I try to insert values into the table, in which the name and shares values are the same, it will return the #1062 error. For example, If i inserted:
fb 4 6 20 20
它将返回错误.但是,如果我将共享数更改为6,它将可以正常运行.是因为我的其中一列可能是唯一的,还是仅与mysql有关?
It would return an error. But if i changed the shares number to 6, it would run fine. Is it because of one of my columns that could be unique, or is it just something with mysql?
推荐答案
您需要删除shares
作为PRIMARY KEY
或UNIQUE_KEY
这篇关于#1062-密钥"PRIMARY"的重复条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!