Analysis of MySQL data types and database creation policies I. digital types
The number types are classified into three types by my classification: integer, decimal, and number.
My so-called "number classes" refer to DECIMAL and NUMERIC. they are of the same type. Strictly speaking, it is not a numeric type, because they actually save numbers as strings; each digit of his value (including the decimal point) occupies a byte storage space, therefore, this type consumes a lot of space. However, one of its outstanding advantages is that the number of digits in decimal places is fixed and will not be "distorted" in the computation ", therefore, it is suitable for "price" and "amount" fields with low precision requirements but high accuracy requirements.
Decimal type, that is, the floating point type. FLOAT and DOUBLE types are supported based on the precision. Their advantage is accuracy. FLOAT can indicate that the absolute value is very small, as small as about 1.17E-38 (0. 000... 0117, 37 digits after the decimal point), and DOUBLE can indicate that the absolute value is smaller than about 2.22E-308 (0. 000... 0222, with a decimal point followed by 307 zeros. The storage space occupied by FLOAT and DOUBLE types is 4 bytes and 8 bytes respectively. If you need to use decimal fields, the precision requirement is not high. of course, FLOAT is used. But to be honest, how does our "civil" data require high accuracy? I have never used these two types