11.8 Choosing the Right Type for a Column为列选择正确的类型

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. 例如,如果整数列用于199999之间的值,则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位整数执行所有计算,然后根据需要将结果转换回浮点值。