MySQL Value Type

Source: Internet
Author: User

The MySQL Manual provides a review of the MySQL numeric data types, which are summarized as follows:

MySQL supports all standard SQL numeric data types. These types include strict data types: integer, smallint, decimal, numeric, and approximate numeric data types: float, real, and double precision. The keyword Int Is the synonym of integer, and DEC is the synonym of decimal.

1 byte = 8 bits). Each user can only be 0 or 1

1B = 8b

1kb = 1024b

1 MB = 1024kb

1G = 1024 MB

1 TB = 1024 GB

1 Pb = 1024 TB

Type

Bytes

Minimum value

Maximum Value

 

 

(Signed/unsigned)

(Signed/unsigned)

Tinyint

1

-128 (-2 ^ 7)

127 (+ 2 ^ 7)

 

 

0

255 (2 ^ 8)

Smallint

2

-32768 (-2 ^ 15)

32767 (+ 2 ^ 15)

 

 

0

65535 (2 ^ 16)

Mediumint

3

-8388608 (-2 ^ 23)

8388607 (+ 2 ^ 23)

 

 

0

16777215 (2 ^ 24)

Int

4

-2147483648 (-2 ^ 31)

2147483647 (+ 2 ^ 31)

 

 

0

4294967295 (2 ^ 32)

Bigint

8

-9223372036854775808 (-2 ^ 63)

9223372036854775807 (+ 63)

 

 

0

18446744073709551615 (2 ^ 64)

 

Another problem is that when defining a value type, we will specify a width value: int (5), which indicates a realistic width, however, the stored value is not only saved to five digits. This has nothing to do with the length of the value that can be saved. For example: int (5), you can actually store 12345678 without any problems.

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.