MySQL Create table-data_type length--CLWU

Source: Internet
Author: User
Tags mysql create mysql create table

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.