下面是我的一些操作,你看看对你有没有帮助:
mysql> create table aa(id int not null auto_increment primary key,
    -> flt float(4,2) not null);
Query OK, 0 rows affected (0.17 sec)mysql> insert into aa values(1,34.29999992);
Query OK, 1 row affected (0.06 sec)mysql> select * from aa;
+----+-------+
| id | flt   |
+----+-------+
|  1 | 34.30 |
+----+-------+
1 row in set (0.02 sec)mysql> alter table aa add column ft float(4,0);
Query OK, 1 row affected (0.14 sec)
Records: 1  Duplicates: 0  Warnings: 0mysql> select * from aa;
+----+-------+------+
| id | flt   | ft   |
+----+-------+------+
|  1 | 34.30 | NULL |
+----+-------+------+
1 row in set (0.03 sec)mysql> update aa set ft=34.29999992 where id=1;
Query OK, 1 row affected (0.06 sec)
Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from aa;
+----+-------+------+
| id | flt   | ft   |
+----+-------+------+
|  1 | 34.30 |   34 |
+----+-------+------+
1 row in set (0.00 sec)说明:float默认是保留8位小数的.
float(M,D)函数,M是你想数据保留的位数(长度),D是小数位的位数.