Learning MySQL data type (iv)

Source: Internet
Author: User

First, integer Type :

Integer type

Bytes occupied

Minimum value

Maximum Value

TINYINT

1

Signed-128

Unsigned 0

Signed 127

Unsigned 255

SMALLINT

2

Signed-3 2768

Unsigned 0

Signed 3 2767

Unsigned 6 5535

Mediumint

3

Signed-83 8608

Unsigned 0

Signed 838 8607

Unsigned 1677 7215

Int/integer

4

Signed-21 4748 3648

Unsigned 0

unsigned 21 4748 3647

Unsigned 42 9496 7295

BIGINT

8

Signed -9E19

Unsigned 0

Signed 9E19

unsigned 1E20

Second, floating-point type:

Determine which floating-point type to use, according to the actual situation, when the need to be accurate to 10 digits after the decimal point, you need to select Double.

Floating-point type

Bytes occupied

Minimum value

Maximum Value

FLOAT

4

±1.75494651e-38

±3.402823466e+38

DOUBLE

8

±2.2250738585072014e-308

±1.7976931348623157e+308

Second, String Type

    1. 1. CHAR Series String

Stores a small number of characters. If the stored string length changes frequently, you can choose varchar.

String type

Bytes occupied

Describe

CHAR (M)

M

M is an integer between (0 ~ 255)

VARCHAR (M)

M

M is an integer between (0 ~ 6 5535)

    1. 2. TEXT Series String

String type

Bytes occupied

Describe

Tinytext

0~255

the length of the value is +2 of bytes

TEXT

0~6 5535

the length of the value is +2 of bytes

Mediumtext

0~1 6777 2150

the length of the value is +3 of bytes

Longtext

0~42 9496 7295

the length of the value is +4 of bytes

    1. 3. BINARY Series String

Very similar to the Char series, but binary can store binary data (picture, audio, video). When the stored binary data length changes frequently, you can choose varbinary.

String type

Bytes occupied

Describe

BINARY (M)

M

allow length to 0~m

VARBINARY (M)

M

allow length to 0~m

    1. 4. BLOB Series String

Similar to the text series, but BLOBs can store binary data (picture, audio, video).

String type

Bytes

Tinyblob

0~255

Blob

0~2 of the - Sub-party (64KB)

Mediumblob

0~2 of the - Sub-party (16MB)

Longblob

0~2 of the + Sub-party (4GB)

Third, date and Time type

Date and Time type

Bytes occupied

Minimum value

Maximum Value

DATE

4

1000-01-01

9999-12-31

Daettime

8

1000-01-01 00:00:00

9999-12-31 23:59:59

TIMESTAMP

4

19700101080001

2038 at some point

Time

3

-835:59:59

835:59:59

Year

1

1901

2155

Four, fixed-point number types

    The range of valid values, determined by M and D.

Fixed-point number types

Bytes occupied

Minimum value

Maximum Value

DEC (m,d)/decial (m,d)

M+2

Same as Double

Same as Double

Five, bit type

Bit type

Bytes occupied

Minimum value

Maximum Value

BIT (M)

1~8

BIT (1)

BIT (64)

Learning MySQL data type (iv)

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.