For optimum storage, you should try to use the most precise type in all cases. For example, if an integer column is used for values in the range from 1
to 99999
, MEDIUMINT UNSIGNED
is the best type. Of the types that represent all the required values, this type uses the least amount of storage.
为了获得最佳的存储效果,您应该在所有情况下尝试使用最精确的类型。例如,如果整数列用于范围从1到99999的值,则MEDIUMINT UNSIGNED是最好的类型。在表示所有所需值的类型中,这种类型使用的存储空间最少。
All basic calculations (+
, -
, *
, and /
) with DECIMAL columns are done with precision of 65 decimal (base 10) digits. See Section 11.1.1, “Numeric Data Type Syntax”.
所有使用DECIMAL列的基本计算(+、-、*和/)都以65位小数(以10为基数)的精度完成。请参见11.1.1节“数字数据类型语法”。
If accuracy is not too important or if speed is the highest priority, the DOUBLE type may be good enough. For high precision, you can always convert to a fixed-point type stored in a BIGINT. This enables you to do all calculations with 64-bit integers and then convert results back to floating-point values as necessary.
如果精度不是太重要,或者速度是最重要的,DOUBLE型可能已经足够好了。对于高精度,您可以始终转换为存储在BIGINT中的定点类型。这使您能够使用64位整数进行所有计算,然后根据需要将结果转换回浮点值。