A great place to be!
int(11)really means. Their confusion is understandable. Many know what defining a
char(10)means (a fixed-sized character string that allows up to 10 characters). However, ints are different.
|Type||# of bytes|
intis always 4 bytes. That can store signed numbers from -2 billion to +2 billion (and unsigned numbers 0 to 4B). So, what does it mean if you declare an
int(5)? It does not restrict the number of digits to 5... It may actually do nothing! The (5) part is a display width. It's only used if you use UNSIGNED and ZEROFILL with an integer type. Then the display of those numbers will be zero-padded on the left to 5 digits if they contain less than 5 digits. Example:
CREATE TABLE `foo` (
`bar` int(5) unsigned zerofill DEFAULT NULL
SELECT * FROM foo; +---------+
| bar |
| 00042 |
| 00101 |
| 9876543 |