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'

原文地址:https://www.cnblogs.com/hankyoon/p/11012576.html

时间: 2024-11-05 16:11:56

ERROR 1062 (23000): Duplicate entry for key 'PRIMARY'的相关文章

ERROR 1062 (23000): Duplicate entry &#39;0&#39; for key &#39;PRIMARY&#39;

OS: centos 6.3DB: 5.5.14 测试创建yoon测试表,没有主键,没有索引,基础数据内容如下: mysql> select * from yoon;+----+----------+------+| id | name | user |+----+----------+------+| 1 | \""##!aa | NULL || 2 | z2 | NULL || 3 | z3 | NULL || 4 | z4 | NULL || 5 | z5 | NULL |

ERROR 1062 (23000): Duplicate entry &#39;1-1&#39; for key &#39;PRIMARY&#39;

这个错误是说,由于某个SQL操作造成了,表中主键重复. 例子: create table t(x int,y int,z int, primary key(x,y)); insert into t(x,y,z) values(1,1,0),(1,2,0),(1,3,0); --在这里还是好的,下面我们要用一条语句来造成错误-- update t set y=1;-- 看到了没有,这一条语句会造成,三行重复的数据,所以它就报错了哦. ERROR 1062 (23000): Duplicate en

ERROR 1130: Host &#39;192.168.1.3&#39; is not allowed to connect to this MySQL ERROR 1062 (23000): Duplicate entry &#39;%-root&#39; for key &#39;PRIMARY&#39;

use mysql mysql> select host, user from user; 将相应用户数据表中的host字段改成'%': update user set host='%' where user='root'; ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 不予理会 flush privileges; 重新远程连接OK ERROR 1130: Host '192.168.1.3' is not allo

利用python将文本文件导入数据库时,报错:Duplicate entry &#39;...&#39; for key &#39;PRIMARY&#39;

错误原因就是添加了相同的主键,我想了好一会儿,我抓的数据主键是Isbn啊,不可能重的啊,于是,我去数据库中查了以下报错的isbn号,插入的数据中也有,因为分类不一样,所以要再插入一次,这就肯定会报错啦,其中一个处理方法就是, 如果数据库中有这条记录,那么就跳过这条记录,另外,还可以在跳过这条记录的同时,把数据库中这本书的类别改为这两种类别. ans = con.execute("select * from b where isbn=(%s)",isbn)if (ans): contin

MySQL - ERROR 1062 (23000)

1.1.1  现象 执行数据库操作,出现如下错误信息: ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY' 1.1.2  原因 出问题的表之前主键是没有设置为自动增长列的,后来程序需要就将其修改为自动增长列,结果插入第一条数据,主键为0,以后再增加数据,就出现如上错误,看信息是以后每次增加数据,其主键都为0,所以导致这个错误. 估计是表之前创建的时候主键不是自动增长列,后来修改为自动增长列,但是MYSQL引擎识别出现了问题. 1.1

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

Mysql连接报错:java.sql.SQLException:null,message from server:"Host '27,45,38,132' is not allowed to connect. 原因是:远程服务器不允许你的java程序访问它的数据库.所以,我们要对远程服务器进行设置,使它允许你进行连接. 工具sqldeveloper连接远程的MySQL 数据库时,配置连接信息,连接发生错误,提示:message from server: "Host '192.168.1

mysql Duplicate entry &#39;9223372036854775807&#39; for key &#39;PRIMARY&#39;

mysql插入数据报错提示: ERROR 1062(23000) Duplicate entry  '9223372036854775807' for key 'PRIMARY' 发现问题果断 直接 把字段改成无符号的类型UNSIGNED 7.BIGINT[(M)] [UNSIGNED] [ZEROFILL] M默认为20 大整数.带符号的范围是-9223372036854775808到9223372036854775807.无符号的范围是0到18446744073709551615. 提示:这

遇到的错误:Mysql 报错Duplicate entry &#39;值&#39; for key &#39;字段名&#39;的解决

### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'admin' for key 'user_name_unique' ### The error may involve com.mmall.dao.UserMapper.insert-Inline ### The error occurred

mysql IntegrityError: (pymysql.err.IntegrityError) (1062, &quot;Duplicate entry &#39;000001.SZ-2018-07-02&#39; for key &#39;PRIMARY&#39;&quot;)

IntegrityError: (pymysql.err.IntegrityError) (1062, "Duplicate entry '000001.SZ-2018-07-02' for key 'PRIMARY'")[SQL: INSERT INTO stock_daily_basic (ts_code, trade_date, close, turnover_rate, turnover_rate_f, volume_ratio, pe, pe_ttm, pb, ps, ps_