Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use unsigned in mysql

Shulou Source: shulou.com Published: 2022-05-31 19:25:17 11月14日 Update

I believe many inexperienced people don't know what to do about how to use unsigned in mysql. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Since unsigned is a non-negative number, you can increase the data length with this type!

For example, if the maximum tinyint is 127, then the maximum tinyint unsigned can be 127x2

The unsigned attribute is only for integers, while the binary attribute is only used for char and varchar.

Www.2cto.com

Types

Description

Tinyint

A very small integer

Smallint

Smaller integer

Mediumint

Medium size integer

Int

Standard integer

Bigint

Larger integer

Float

Single precision floating point number

Double

Double precision floating point number

Decimal

The floating point number of a string

The name and range of values for each numeric type are shown in Table 2.

Type description

Value range

Tinyint [(m)]

Have symbolic values:-128 to 127 (- 27 to 27-1)

Unsigned values: 0 to 255 (0 to 28-1) 1 byte

Smallint [(m)] www.2cto.com

Have symbolic values:-32768 to 32767

Unsigned values: 0 to 65535 (0 to 21 6-1) 2 bytes

Mediumint [(m)]

Have symbolic values:-8388608 to 8388607 (- 22 3 to 22 3-1)

Unsigned values: 0 to 16777215 (0 to 22 4-1) 3 bytes

Int [(m)]

Have symbolic values:-2147683648 to 2147683647 (- 231 to 231-1)

Unsigned values: 0 to 4294967295 (0 to 4294967295 # 1) 4 bytes

Bigint [(m)]

Symbolic values:-9223372036854775808 to 9223373036854775807 (- 263 to 263-1)

Unsigned values: 0 to 18446744073709551615 (0 to 264-1) 8 bytes

Float [(m, d)]

Minimum non-zero value: ±1.175494351e-38

Double [(m _ m _ d)]

Minimum non-zero value: ±2.2250738585072014e-308

Decimal (m, d)

Variable; the range of values depends on m and d

Table 2: range of values for numeric column types

The amount of storage required for various types of values is shown in Table 3.

Type description www.2cto.com

Storage requirement

Tinyint [(m)]

1 byte

Smallint [(m)]

2 byt

Mediumint [(m)]

3 bytes

Int [(m)]

4 byt

Bigint [(m)]

8 byte

Float [(m, d)]

4 byt

Double [(m, d)]

8 byte

Decimal (m, d)

M bytes (

< 3.23),m+2字节(mysql >

3.23)

Table 3: storage requirements for numeric column types www.2cto.com

Mysql provides five integers: tinyint, smallint, mediumint, int, and bigint. Int is the abbreviation of integer. These types are different in the range of representable values. Integer columns can be defined as unsigned to disable negative values; this makes the range of values for the column above 0. Different types of storage requirements are also different. Types with a wide range of values require a larger amount of storage.

Mysql provides three floating-point types: float, double, and decimal. Unlike integers, floating-point types cannot be unsigned, and their range of values is different from integers, not only in that these types have a maximum value, but also a minimum non-zero value. The minimum value provides a measure of the corresponding type of accuracy, which is very important for recording scientific data (of course, there are negative maximum and minimum values).

After reading the above, have you mastered how to use unsigned in mysql? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Type byte symbol range different minimum integer storage maximum larger storage numeric point demand content property data method more floating point Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB OPPO Reno NVidia Redmi