I was wondering what the difference between BigInt, MediumInt, and Int are… it would seem obvious that they would allow for larger numbers; however, I can make an Int(20) or a BigInt(20) and that would make seem that it is not necessarily about size.
Some insight would be awesome, just kind of curious. I have been using MySQL for a while and trying to apply business needs when choosing types, but I never understood this aspect.
See http://dev.mysql.com/doc/refman/8.0/en/numeric-types.html
INTis a four-byte signed integer.BIGINTis an eight-byte signed integer.They each accept no more and no fewer values than can be stored in their respective number of bytes. That means 232 values in an
INTand 264 values in aBIGINT.The 20 in
INT(20)andBIGINT(20)means almost nothing. It’s a hint for display width. It has nothing to do with storage, nor the range of values that column will accept.Practically, it affects only the
ZEROFILLoption:It’s a common source of confusion for MySQL users to see
INT(20)and assume it’s a size limit, something analogous toCHAR(20). This is not the case.