In MySQL table definitions is there a different between
SMALLINT(5)? Or do they both represent the same size?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
No, they don't represent the same size that is allocated for the field type.
An int can be between -2147483648 and 2147483647 signed, or 0 and 4294967295 unsigned.
A smallint is between -32768 and 32767 signed, or 0 and 65535 unsigned.
The (5) represents the display width of the field. From the manual, it states:
The display width, from what I can tell, can be used to left-pad numbers that are less than the defined width. So 00322, instead of 322. TBH, I've never used it.
But it doesn't affect the storage size of the column. An int will take up more space than a smallint.