mysql - 主键已自增,1062 Duplicate entry '146' for key 'PRIMARY'
PHPz
PHPz 2017-04-17 13:54:57
0
2
661

错误:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '146' for key 'PRIMARY' (SQL: insert into `staff` (`user_id`, `agent_id`, `created_at`) values (363, 2121, 1457079046))

表结构中主键为 id,自增,146这个条记录确实也存在,插入时,我没有提供id的值,理论上应该是要自增的,既然自增,理论上不应该存在主键重复的问题。

表结构:

请问什么样的情况会出现这种的问题?

谢谢啦!

PHPz
PHPz

学习是最好的投资!

reply all(2)
巴扎黑

The primary key is repeated. Isn’t it clearly written?

Peter_Zhu

Just looking at the table structure and sql statements, there seems to be no problem. It should be able to be inserted normally

So is it because you used transactions and the previous statement had an impact on this SQL? It’s best to post the code if it’s convenient

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!