Skip to content
Advertisement

ERROR 1062 (23000): Duplicate entry ‘2147483647’ for key ‘PRIMARY’

I have a table:

As we can see, the previous value, just went wrong into table. Should be 16 numbers and not only 10, actually different numbers.
When i try to insert a new value:

I get this error:

ERROR 1062 (23000): Duplicate entry ‘2147483647’ for key ‘PRIMARY’

If bank_card is AUTO_INCREMENT why there is error? Should I change the PK to another place?

Advertisement

Answer

INT has a maximum signed value of 2147483647. Any number greater than that will be truncated to that value. What you need to do is change that column to be a varchar(20) which will hold strings of up to 20 characters since bank card numbers are strings and not actually numbers (you don’t do math with the). You also should remove AUTO_INCREMENT as that is not a value you will be incrementing.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement