MySQL中所有数值型数据,统称为Numeric Type
各字段类型中:
DECIMAL和NUMERIC意义相等,用法相同,都是是fixed-point type(exact value)
FLOAT/DOUBLE 类型,分别代表单精度浮点/双精度浮点类型。不管如何提高精度,也是floating-point type(approximate value),用来进行高精度计算会出问题;auto_increment特性在版本8从这两种类型上弃用。这两种类型后续也将被弃用。
附录如下:
DATA TYPE | 字段类型 | 说明 |
Numeric Type
|
BIT |
bit-value type,取值范围1-64,若不指定默认为1 BIT(M)类型在赋值时,如果没有完全用完位数会自动填充补齐 e.g. assigning a value of b'101' to a BIT(6) column is, in effect, the same as assigning b'000101' |
TINYINT |
取值范围 -128 ~ 127(signed),0 ~255(unsigned) |
|
BOOL/BOOLE |