I am facing a problem 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
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
By default MySQL stores your
INT(20)as unsigned integer on 4 bytes:INT(4). This means you have a range between-2147483648and2147483647and probably you’re overflowing to negative values. Usingunsignedgives you a range between0and4294967295. You should consider using BIGINT(8). See the documentation on numeric types and how MySQL handles overflow!