Original Address: https: //blog.csdn.net/allenjay11/article/details/76549503
Today when adding data and found that when the data type is int (11), when I had to let users add data, the maximum input length is 11 bits, the result, adding data is not added on, cause problems, I changed the maximum length is 10, the result of verification is 9 1 is normal, validation 9 9 again when they failed.
After the query data, and ultimately find a presentation on the mysql data type int (11) of
In the SQL statement int represents the type of field you want to create, int represents the integer length of 11 representatives of the fields.
The 11 represents the display width, integer column widths and mysql show how many characters used to display the list of numbers, and the size of the storage space required for this integer does not matter, for example, whether to set the display width is the number of characters, bigint 8 bytes to be occupied.
int is an integer, (11) refers to the display of characters in length, but to increase the parameter, a maximum of 255, such as it is the number of rows id, the pen 10 is inserted into the information, it displays 00000000001 00000000010 ~~~, when the character more than 11 digits, it also shows only 11, if you did not add that it is less than 11 on the front plus 0 parameter, it will not add 0 in front
When declaring an integer column data, we can specify that a display width M (1 ~ 255), such as INT (5), specify the display width of 5 characters, if it is not designated to display width, MySQL assigns it a Defaults. Display width for display only, and not to limit the range and space, such as: INT (3) will be 4 bytes of storage space, and will not be the maximum allowed 999, but as INT The the maximum allowed.
There are five columns MySQL integer data type, namely TINYINT, SMALLINT, MEDIUMINT, INT and BIGINT. The difference between them is a different range of values, storage space is also different.
After the integer data column plus UNSIGNED attribute suppresses negative values from zero.