Usage of unsigned in mysql

Source: Internet
Author: User


Unsigned is a non-negative number. You can use this type to increase the data length! For example, if the maximum value of tinyint is 127, the maximum value of tinyint unsigned can be 127*2. the unsigned attribute is only for integer type, and the binary Attribute is only for char and varchar type. Www.2cto.com type description tinyint very small integer smallint smaller integer mediumint medium size integer int standard integer bigint larger integer float single precision Floating Point double precision Floating Point Number decimal a string floating point each value type name and the value range is shown in table 2. Type description value range: tinyint [(m)] signed value:-128 to 127 (-27 to 27-1) unsigned value: 0 to 255 (0 to 28-1) 1 byte smallint [(m)] www.2cto.com signed value:-32768 to 32767 (-215 to 215-1) unsigned value: 0 to 65535 (0 to 21 6-1) 2 bytes mediumint [(m)] signed value:-8388608 to 8388607 (-22 3 to 22 3-1) unsigned value: 0 to 16777215 (0 to 22 4-1) 3 bytes int [(m)] signed value:-2147683648 to 2147683647 (-231 to 231-1) unsigned value: 0 to 4294967295 (0 to 232-1) 4-byte bigint [(m)] signed value:-9223372036854775808 to 9223373036854775807 (-263 To 263-1) unsigned value: 0 to 18446744073709551615 (0 to 264-1) 8 bytes float [(m, d)] minimum non-zero value: ± 1. 175494351e-38 double [(m, d)] minimum non-zero value: ± 2. 225074255072014e-308 decimal (m, d) variable; its value range depends on m and d Table 2: The storage required for values of various types of values in the value column type is shown in table 3. Type Description: storage requirements for www.2cto.com tinyint [(m)] 1-byte smallint [(m)] 2-byte mediumint [(m)] 3-byte int [(m)] 4-byte bigint [(m)] 8-byte float [(m, d)] 4-byte double [(m, d)] 8-byte decimal (m, d) m-byte (mysql <3.23), m + 2-byte (mysql> 3.23) Table 3: Data column storage requirements www.2cto.com mysql provides five types of integers: tinyint, smallint, mediumint, int, and bigint. Int is the abbreviation of integer. These types are different in the value range that can be expressed. An integer column can be defined as unsigned to disable negative values. This enables the value range of the column to be greater than 0. Different types of storage requirements are also different. The storage required for a type with a large value range is large. Mysql provides three floating point types: float, double, and decimal. Different from integer types, the floating point type cannot be unsigned, and its value range is also different from that of integer types. The difference is that these types have the maximum value and the minimum non-zero value. The minimum value provides a metric of the corresponding type of precision, which is very important for recording scientific data (of course, there are also the maximum and minimum values of negative values ). Author kwishly

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.