Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'

后端 未结 4 1790
旧时难觅i
旧时难觅i 2021-02-19 09:23

I have a databse problem where i get Integrity constraint violation: 1062. I tried some things on my own but it didtn work so now i am asking you guys to see if you people can h

相关标签:
4条回答
  • 2021-02-19 09:53

    I had the same problem, and it was not the auto increment that was causing it. I changed the data type on my table ID from TINYINT(3) to INT(10). Try that. Maybe it'll help.

    0 讨论(0)
  • 2021-02-19 09:58

    When inserting into a table with an auto increment field, the auto increment field itself should not be specified at all.

    Query("INSERT INTO prod_categorie (categorieID, parentID) VALUES (?, ?)", array($chkParent, $txtParentCategorie));
                                       ^^^^^^^^^^^                    ^             ^^^^^^^^^^
    

    Should be just

    Query("INSERT INTO prod_categorie (parentID) VALUES (?)", array($txtParentCategorie));
    

    Just added as answer from comment discussion to allow accept and finishing the question.

    0 讨论(0)
  • 2021-02-19 09:58

    I came across this problem when using Magento 2 with the Google Experiment set to Yes. Simply shutting it off solved my page save issue. Bu ti'm still having a problem with adding catalog products it give me an error that the URL Key for the specified store already exists. and the image is not uploading even though i have correct folder permissions. Will post an update in case it helps anyone else.

    0 讨论(0)
  • 2021-02-19 10:05

    in my case the error is:

    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'

    the solution is to Empty/Truncate all records of the table in question

    The problem happens when auto-increment is disabled on the primary-key of that table or the data-type is wrong.

    partially credited to https://magento.stackexchange.com/questions/56354/admin-error-sqlstate23000-integrity-constraint-violation-1062-duplicate-ent

    0 讨论(0)
提交回复
热议问题