MySQL中的小数类型有两个调整旋钮:精度和小数位数。您省略了小数位,因此默认为0。
文档([链接](http://dev.mysql.com/doc/refman/5.1/en/precision-math-decimal-
changes.html))
DECIMAL列的声明语法为DECIMAL(M,D)。MySQL 5.1中参数的值范围如下:
M是最大位数(精度)。它的范围是1到65。(较早版本的MySQL允许范围是1到254。)
D是小数点右边的位数(小数位数)。范围是0到30,并且不能大于M。
例子
mysql> create table test01 (field01 decimal(9));Query OK, 0 rows affected (0.01 sec)mysql> insert into test01 (field01) values (123.456);Query OK, 1 row affected, 1 warning (0.00 sec)mysql> select * from test01;+---------+| field01 |+---------+| 123 |+---------+1 row in set (0.00 sec)mysql> create table test02 (field01 decimal(9, 4));Query OK, 0 rows affected (0.00 sec)mysql> insert into test02 (field01) values (123.456);Query OK, 1 row affected (0.01 sec)mysql> select * from test02;+----------+| field01 |+----------+| 123.4560 |+----------+1 row in set (0.00 sec)



