mysql> create table one(
-> id float(3,1)
-> )engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into one (id)values (44.44);
Query OK, 1 row affected (0.00 sec)
mysql> select * from one;
+------+
| id |
+------+
| 44.4 |
+------+
1 row in set (0.00 sec) //这里正常可以明白
mysql> create table two(
-> id float(5,2)
-> )engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into two (id) values(34567.6789);
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> select * from two;
+--------+
| id |
+--------+
| 999.99 |
+--------+
1 row in set (0.00 sec) //这里填充5位整数 而float设置为3位字符受到破坏 所以导致出现999.99
mysql> create table gree(
-> id float(5,2)
-> )engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into gree(id) values(999.446);
Query OK, 1 row affected (0.00 sec)
mysql> select * from gree; //下面可以理解啦
+--------+
| id |
+--------+
| 999.45 |
+--------+
1 row in set (0.00 sec)
mysql> create table four(
-> id float (5,2)
-> )engine=myisam default charset=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into four (id) values(99.123);
Query OK, 1 row affected (0.00 sec)
mysql> select * from four;
+-------+
| id |
+-------+
| 99.12 |
+-------+
1 row in set (0.00 sec)