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. 1
到99999
之间的值,则MEDIUMINT UNSIGNED
是最佳类型。Of the types that represent all the required values, this type uses the least amount of storage.在表示所有必需值的类型中,此类型使用的存储量最少。
All basic calculations (所有带小数列的基本计算(+
, -
, *
, and /
) with DECIMAL
columns are done with precision of 65 decimal (base 10) digits. +
、-
、*
和/
)的精度为65位小数(以10为基数)。See Section 11.1.1, “Numeric Data Type Syntax”.见第11.1.1节,“数字数据类型语法”。
If accuracy is not too important or if speed is the highest priority, the 如果准确度不是很重要,或者速度是最重要的,那么DOUBLE
type may be good enough. DOUBLE
类型就足够了。For high precision, you can always convert to a fixed-point type stored in a 为了获得高精度,可以始终转换为BIGINT
. BIGINT
中存储的定点类型。This enables you to do all calculations with 64-bit integers and then convert results back to floating-point values as necessary.这使您能够使用64位整数执行所有计算,然后根据需要将结果转换回浮点值。