- 论坛徽章:
- 0
|
mysql> desc t1;
+-------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+---------+-------+
| c1 | float(10,2) | YES | | NULL | |
| c2 | decimal(10,2) | YES | | NULL | |
| c3 | float | YES | | NULL | |
+-------+---------------+------+-----+---------+-------+
3 rows in set (0.16 sec)
mysql> insert into t1 values(1234567.23, 1234567.23,1234567.23);
Query OK, 1 row affected (0.12 sec)
mysql> select * from t1;
+------------+------------+--------------+
| c1 | c2 | c3 |
+------------+------------+--------------+
| 1234567.25 | 1234567.23 | 1.23457e+006 |
+------------+------------+--------------+
1 row in set (0.00 sec)
mysql> insert into t1 values(9876543.21, 9876543.12,9876543.21);
Query OK, 1 row affected (0.11 sec)
mysql> select * from t1;
+------------+------------+--------------+
| c1 | c2 | c3 |
+------------+------------+--------------+
| 1234567.25 | 1234567.23 | 1.23457e+006 |
| 9876543.00 | 9876543.12 | 9.87654e+006 |
+------------+------------+--------------+
2 rows in set (0.00 sec)
mysql> select version();
+------------------+
| version() |
+------------------+
| 5.1.32-community |
+------------------+
1 row in set (0.01 sec)
MySQL的float、double和decimal的具体区别,如下,为什么 insert into t1 values(9876543.21, 9876543.12,9876543.21);的时候,float(10,2)的字段值会变成9876543.00 呢? |
|