ERROR 1062 (23000): Duplicate entry for key 'PRIMARY'

Posted hankyoon

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ERROR 1062 (23000): Duplicate entry for key 'PRIMARY'相关的知识,希望对你有一定的参考价值。

ALTER TABLE table1 ADD COLUMN column1 VARCHAR(400) DEFAULT NULL;

ERROR 1062 (23000): Duplicate entry ‘82133627‘ for key ‘PRIMARY‘

select * from table1 where <primary_key_field>=‘82133627‘;

Primary key - primary_key_field int(11) NOT NULL

solution - need to lock table, and then after running the query unlock it

LOCK TABLES "table1" WRITE;

run the alter table command:

ALTER TABLE table1 ADD COLUMN column1 VARCHAR(400) DEFAULT NULL;

then

UNLOCK TABLES;

以上是关于ERROR 1062 (23000): Duplicate entry for key 'PRIMARY'的主要内容,如果未能解决你的问题,请参考以下文章

Mysql报错message from server: ERROR 1062 (23000):

ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'

ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL ERROR 1062 (23000): D

[23000][1062] 键 'PRIMARY' 的重复条目 '0'

SQLSTATE [23000]:完整性约束违规:1062 键 'tbl_item_item_ID_UNIQUE' 的重复条目 '25'

SQLSTATE [23000]:违反完整性限制:1062 'mail@mail.com' 'users_email_unique' 键的重复条目