Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
Thread: int and (numbers)
10-31-2011, 09:30 AM #1
- Join Date
- Sep 2011
- Thanked 0 Times in 0 Posts
int and (numbers)
I have recently used (int)11. I am wondering what the 11 represents and if there are other numbers that can be used with int, such as int(10) or int(12) etc?
10-31-2011, 01:04 PM #2
- Join Date
- Aug 2003
- Wake Forest, North Carolina
- Thanked 204 Times in 201 Posts
From the MySQL manual:
MySQL supports an extension for optionally specifying the display width of integer data types in parentheses following the base keyword for the type. For example, INT(4) specifies an INT with a display width of four digits. This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. (That is, this width is present in the metadata returned with result sets. Whether it is used or not is up to the application.)
The display width does not constrain the range of values that can be stored in the column. Nor does it prevent values wider than the column display width from being displayed correctly.
Dave .... HostMonster for all of your hosting needs
10-31-2011, 07:35 PM #3
In other words, who cares about (11) or (12) or any other number there.
It *ONLY* matters if you are using the mysql command line client, where it affects only the display. (And of course some GUI tools can optionally use the information.)
If you are connecting to MySQL from PHP or other web technology, it has likely has zero impact on you.
I, personally, never bother to specify a size for int and float types.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.