PHPAdmin database negative primary key
I am facing a probl开发者_运维问答em with my phpadmin database. My primary key for a table got negative and I can't see where the problem lies. I set the primary key as INT 20, auto increment 1. The negative integer is not a small number
By default MySQL stores your INT(20)
as unsigned integer on 4 bytes: INT(4)
. This means you have a range between -2147483648
and 2147483647
and probably you're overflowing to negative values. Using unsigned
gives you a range between 0
and 4294967295
. You should consider using BIGINT(8). See the documentation on numeric types and how MySQL handles overflow!
精彩评论