search

Home  >  Q&A  >  body text

php - Error 1062:Duplicate entry '4294967295' for key 'PRIMARY'

There are only hundreds of thousands of data in my database. The primary key is int 11. I could insert it before, but now I will get this error.
Please answer. Thank you

漂亮男人漂亮男人2724 days ago1106

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-06-17 09:17:21

    First let’s clarify a few concepts

    1. The final size of the value stored in int(11) and int(3) is the same. The 3 and 11 are the length of the number when displayed on the terminal, and have nothing to do with the size and length of the stored number

    2. With 110,000 data, your primary key should not be the step size plus 1, or your id may not start from incrementing 0.

    3. The person above has explained the reason clearly, saying that the primary key value is duplicated, so first go to the database to find this record, and then look at the data of more than 100,000, why the primary key is 4294967295

    4. 2 to the 32nd power = 4294967296 (unsigned), signed and then divided by 2, there is one more negative number than positive number, -2147483648~+2147483647 int type unsigned 4294967296 maximum value

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-17 09:17:21

    This is a duplicate key, try this, it is not guaranteed to work...
    step 1: select max(your primary_key_field) from your_table_name;
    step 2: ALTER TABLE your_table_name AUTO_INCREMENT = value_u_got_from_step1 + 1;

    reply
    0
  • PHP中文网

    PHP中文网2017-06-17 09:17:21

    The id auto-increment has reached the upper limit. If you insert data again, you can only insert this id value, so there will be a conflict. Just change it to bigint type. Hundreds of thousands of data will auto-increment to this value. You need to check your auto-increment. Rules and business logic, otherwise the limit will be reached very quickly at your speed

    reply
    0
  • Cancelreply