You are here: Home > FAQ > MySQL int (M) instruction

FAQ

MySQL int (M) instruction

Of x in the meaning of int(x)
The width of this optional specifications for, when the displayed value, the value of some values ??of the width of the short-width of the column to the left to fill the display, but not to limit the the value stored in the column width, which is not intended to limit the specified value exceeds the column width to the number of digits to be displayed. Note that if the value stored in a larger width than is displayed in an integer column, when mysql generate a temporary table for some complex link (join), you may encounter problems because in this case, mysql Trust believes that all values ??are suitable for the original column width.

The int is 4 bytes bigint itself is 8 bytes so that int (x) is the meaning of the stored data byte int decide column width x represents the desired data. In sql statement int mean you want to create the type of the field, Representative int Integer, 11 denotes a length of the field.  It representatives of the display width。
 
Integer column display width and mysql how many characters used to display the column value, and the size of the storage space required for the integer does not matter, for example, regardless of the setting of the display width is the number of characters, bigint are to occupy 8 bytes.

As an extension of the ansi / iso sql92 standards, mysql also supports integer type tinyint, mediumint and bigint. Another extension is mysql support arbitrary integer value specifying a display format, this is done by a parenthesis in the type of basic keyword followed to achieve (such as int (4)). The width of the optional specifications for, when the displayed value, the value of some values ??of the width of the short-width of the column to the left to fill the display, and not intended to limit the width of the value stored in the column is not intended to limit values ??that exceed the width of the column specified number of digits can be displayed. When used with the optional extension attribute zerofill, the default is to fill the spaces with zero instead. For example, a column is defined as int (5) zerofill, insert the value 4 is retrieved as 00004. Note that if the value stored in a larger width than is displayed in an integer column, when mysql generate a temporary table for some complex link (join), you may encounter problems because in this case, mysql Trust believes that all values ??are suitable for the original column width, int (m), integer (m) 32-bit integer (4 bytes ....)

In fact, the scope of this m with int no relationship can be expressed, as long as you choose int, int is 4 bytes, one byte 8, represents unsigned range if the number of hours that can be represented 0 ------- 232-1, you can store any within this range numbers.

Somehow relationship, mysql has a zerofll, select the storage will be very different when after 0 padding built table, then if you choose int (4) you store 12 database Storage is 0012, if fill 12345, this time over a specified width is untouched his store.