Length problem with MySQL shaping

Source: Internet
Author: User

tinyint

The signed range is 128 to 127;

The unsigned range is 0 to 255, 2 of 8 square-1;

The storage size is 1 bytes.

smallint

The signed range is 32768 to 32767;

The unsigned range is 0 to 65535, 2 of 16 square-1;

The storage size is 2 bytes.

Mediumint

The signed range is 8388608 to 8388607;

The unsigned range is 0 to 16777215, 2 of 24 square-1;

The storage size is 3 bytes.

int

The signed range is 2147483648 to 2147483647;

The unsigned range is 0 to 4294967295, 2 of 32 square-1;
The storage size is 4 bytes.

bigint

The signed range is 9223372036854775808 to 9223372036854775807;

The unsigned range is 0 to 18446744073709551615, 2 of 64 square-1;

The storage size is 8 bytes.

MySQL in the Int (1) and tinyint (1) in the 1 is only the specified display length, does not indicate the storage length, only the field specified Zerofill useful
For example: Int (3), if the actual value is 2, if the column specifies Zerofill, the query result is 002 and the left is filled with zeros.

Note: Although the mobile phone number is generally a pure number, but the number of bits is longer, if the type of int, if the field is set unsigned will be stored as the maximum value of 4294967295,int, so if you want to use the shaping can be used bigint (1), but the general web-based data display mobile phone number this field, To avoid all kinds of problems, use varchar more.

Length problem with MySQL shaping

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.