Numeric type
MySQL’s integer type
Type | occupied Storage space (unit) | Unsigned value range | There is a matching value range | Definition |
---|---|---|---|---|
1 | 0 ~ 2⁸-1 | -2⁷ ~ 2⁷-1 | Very small integer | |
2 | 0 ~ 2¹⁶-1 | -2¹⁶ ~ 2¹⁶-1 | Small integer | |
3 | 0 ~ 2²⁴-1 | -2²⁴ ~ 2²⁴-1 | MEDIUM INTEGER | |
4 | 0 ~ 2³²-1 | -2³² ~ 2³²-1 | Standard Integer | |
8 | 0 ~ 2⁶⁴-1 | -2⁶⁴ ~ 2⁶⁴-1 | Large integer |
Occupied storage space (unit) | Minimum absolute value non-0 value | Maximum absolute value non-0 value | Definition | |
---|---|---|---|---|
4 | ±1.175494351E-38 | ±3.402823466E 38 | Single precision floating point number | ##DOUBLE |
##±2.2250738585072014E-308 | ##±1.7976931348623157E 308Double-precision floating-point number |
Set the maximum number of digits and decimal places
In When defining the floating-point number type, you can also follow FLOAT or DOUBLE with two parameters, as follows
FLOAT(M, D) DOUBLE(M, D)
M represents the maximum number of significant decimal digits required for the decimal D represents the decimal The number of decimal digits after the decimal point
TypeValue rangeFLOAT(4, 0) | |
---|---|
FLOAT(4, 2) | -99.96 ~ 99.99 |
FLOAT(4, 1) | -999.9 ~ 999.9 |
-9999.9 ~ 9999.9 | |
-99999.9 ~ 99999.9 | |
In the same situation as D , the larger M is, the larger the value range of this type is; when M is the same, the larger D is, the smaller the value range of this type is. | The value range of M is 1~255, the value range of D is 0~30, and the value of D must not be greater than M. M and D are optional. If we omit them, their values are stored according to the maximum value supported by the machine. |
Type
Storage space occupied (unit: bytes)
DECLMAL | Depends on M and D | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
#The number of decimal digits contained in the group | The storage space occupied by the unit (bytes ) |
---|---|
1 or 2 | 1 |
3 or 4 | 2 |
3 | |
4 |
Recommended tutorial: "
The above is the detailed content of Detailed explanation of data types in MySQL. For more information, please follow other related articles on the PHP Chinese website!