DF Learn MySQL (iii)--MYSQL data type

Source: Internet
Author: User

MySQL data types are divided into:
Integer type, floating-point type, fixed-point number type
Date and Time type
String type
Binary type

Integer type byte number unsigned number value range signed number range
TINYINT 1 0-255-128-127
SMALLINT 2 0-65535-32768-32767
Mediumint 3 0-16777215-8388608-8388607
INT 4 0-4294967295-2147483648-2147483647
Intger 4 0-4294967295-2147483648-2147483647
BIGINT 8

Zorefill parameters
Unsigned parameters

Insert data length exceeds set length but does not exceed default length allows insertion

Floating-point type
FLOAT (m,d) M is length, D is the number of digits after the decimal point 4 bytes
DOUBLE (m,d) M is length, D is the number of digits after the decimal point 8 bytes

Rounding when inserting

Fixed-point number types
Decimal (M,D) M is the length and D is the number of digits after the decimal point

Insert intercept, with warning

If you do not specify precision, float and double will save the actual precision by default, but are related to the actual operating system and hardware. Decimal is a 10-bit integer by default.

Date and Time type

Year type represents years;
1 byte yyyy form range 1901-2155 over range becomes 0000
Use two-bit string input: 00 to 69 conversion to 2000 to 2069 input 70 to 99 to 1970-1999

The time type represents the times;
3 byte HH:MM:SS form range -838:59:59 to 838:59:59
"D HH:MM:SS" D for days range 0-34
"HHMMSS" converted to HH:MM:SS0 and ' 0 ' to 0000:00:00
Current_time and now () enter the current time

Date type represents dates
4 bytes Yyyy-mm-dd 1000-01-01 to 9999-12-31
YYYY-MM-DD or YYYYMMDD format input yyyy/mm/dd [email protected] @DD YYYY. Mm. Dd

Dataetime type represents date and time

Timestamp type represents date and time
4 byte form yyyy-mm-dd HH:MM:SS range 1970-0101 08:00:01 to 2038-01-19 11:14:07


String type:

Char type 0-255 length length fixed
varchar type 0-65535 length length variable occupancy actual length +1

Specifying a maximum length string type when creating a table (M)

Text type
Tinytext 0-255 bytes occupied actual length +2
TEXT 0-65535 Bytes occupies actual length +2
Mediumtext occupied actual length +3
Longtext occupied actual length +4

Enum type

Set type

Binary type

Binary and varbinary types

Specifying the maximum type when creating a table

Bit type

Blog type

How do I choose a data type?

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.