[Reserved] MySQL in int (11) The maximum length is how many?

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.

Note: The specific length here represented by M is not stored in the database, used to be mistaken int (3) can only store three digit length, int (11) is stored and the 11 digit length, this is a big mistake.

In fact, when we choose to use type int time, whether int (3) or int (11), it is stored in a database which is 4 bytes in length, and using int (3) If the time you enter is 10, you will default to 010-bit memory, which means that 3 represents a default length when you are less than three, will help you incomplete, when you over three, there would be no impact.

int (10) and int (11) What is the difference, then that is the difference between the length of it, and now look, in addition to a little difference between them when stored outside, when we use is no different.

int (10) can also represent the value 2147483647 int (11) can also represent.

Guess you like

Origin www.cnblogs.com/daizhongxing/p/12074583.html