MySQL Tip: Use unsigned int for larger values
Have you ever created an <b>int</b> field for a primary key? Or perhaps to store a numeric value? Chances are, you probably have, and if you don’t know what <b>unsigned</b> means, you are limiting the number of possible values that can be used in that field.
In MySQL, a field with the data type of int, without unsigned specified is capable of storing negative values. Since auto incremented primary keys will not use negative numbers for identifiers, you are limiting yourself to effectively half of the possible values of the int data type (between 0 and 2147483647).
That may seem like a fairly large number to most of you, but why take the risk? If you specify your integer field as <b>unsigned</b>, you will double the number of values accepted by the field.
<b>Why?</b> A <b>signed</b> integer, which in MySQL are all integers that are not specified as unsigned, will use the first of 32 bits as a marker for negative or positive. This means that the possible values for are 2^31. With an unsigned integer, the values are 2^32, or 0 to 4294967295.
The same exact rules apply for BIGINT (which is signed 2^63 and unsigned 2^64).