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?