When MySQL create table, it is sometimes necessary to specify data_type length
Http://dev.mysql.com/doc/refman/5.5/en/create-table.html
But the length of the type a lot of development does not understand, understanding can be divided into two
1) Number type:
If int is a 4 byte,32 bit,
For signed int, its maximum value is 2**32-1=4294967295, with a signed display of +4294967295 just 11 characters,
for unsigned int its maximum value is 2**31-1=2147483647, which is displayed as 2147483647 exactly 10 characters
As shown, the first create table SQL is my handwriting, the second CREATE table SQL is returned through SHOW CREATE TABLE, the second one is only more than the first one ( length
) 10, 11, but it They are equivalent.
For the number type specified ( length
) is not affect the storage space , there is length
() exist only affect his display length, what is called the display length, C-language printf can specify the output length of the format parameter, this The output length is the so-called display length here.
2) non-numeric type
such as Char, when the type is char (33), it indicates that the field of storage space for the length of the "character", forget MySQL from 5. The character is no longer the byte length, meaning if you use UTF8, then this is the length of the 33 Chinese.
MySQL Create table-data_type length--CLWU