View Full Version : int and (numbers)
10-31-2011, 10:30 AM
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, 02:04 PM
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.
10-31-2011, 08:35 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.