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 ='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;


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28939273/viewspace-2286645/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28939273/viewspace-2286645/

你可能感兴趣的:(ERROR 1062 (23000): Duplicate entry for key 'PRIMARY')