AFAIK, the number in parenthesis is ONLY for display purposes in formatting
the size of the column in mySQL command line output, NOT the size of the
data that can be held.
I think they use (11) because unsigned will need one extra character for
the minus sign.
INT SIGNED = -2147483648 to 2147483647
Now this changes for things like a CHAR(2) where that *IS the column is
only going to handle 2 characters. Or VARCHAR(10) where that column will
handle from 0 to 10 characters. Same goes for FLOAT(7,4) which means 7
total digits and 4 of them are decimal places.
But for *INT columns, I don't think the same is true. It's cosmetic only.
Someone PLEASE correct me if I'm wrong. It's kind of silly if you ask me.
This one special case just adds confusion.
Another extension is supported by MySQL for optionally specifying the
display width of integer data types in parentheses following the base
keyword for the type (for example, INT(4)). 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 the number of digits that are displayed for values
having a width exceeding that specified for the column. For example, a
column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to
32767, and values outside the range allowed by three characters are
displayed using more than three characters.
> -----Original Message-----
> From: Ryan Chan [mailto:ryanchan404@stripped]
> Sent: Monday, June 14, 2010 9:14 AM
> To: MySql
> Subject: int(10) va int(11)
> Assume MySQL int range (unsigned) is from 0 to 4294967295
> There are total 10 digits.
> Why a lot of tutorial in the web tell you to declare,
> CREATE TABLE t1 (f INT(11) UNSIGNED);
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: