php - Error 1062:Duplicate entry '4294967295' for key 'PRIMARY'
漂亮男人2017-06-17 09:15:21
0
3
1075
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
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
With 110,000 data, your primary key should not be the step size plus 1, or your id may not start from incrementing 0.
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
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
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;
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
First let’s clarify a few concepts
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
With 110,000 data, your primary key should not be the step size plus 1, or your id may not start from incrementing 0.
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
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
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;
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