我們在Ubuntu 9.04上使用MySql 5.0。完整版本是:5.0.75-0ubuntu10MySql FLOAT數據類型和多於7位數字的問題
我創建了一個測試數據庫。和一個測試表。我看到下面的輸出從一個INSERT語句:
mysql> CREATE TABLE test (floaty FLOAT(8,2)) engine=InnoDb;
Query OK, 0 rows affected (0.02 sec)
mysql> insert into test value(858147.11);
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM test;
+-----------+
| floaty |
+-----------+
| 858147.12 |
+-----------+
1 row in set (0.00 sec)
似乎有要與規模/精度在MySQL的設置有問題?還是我錯過了什麼?
UPDATE:
發現我們將其中一個號碼的邊界,這裏是代碼:
mysql> CREATE TABLE test (floaty FLOAT(8,2)) engine=InnoDb;
Query OK, 0 rows affected (0.03 sec)
mysql> insert into test value(131071.01);
Query OK, 1 row affected (0.01 sec)
mysql> insert into test value(131072.01);
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM test;
+-----------+
| floaty |
+-----------+
| 131071.01 |
| 131072.02 |
+-----------+
2 rows in set (0.00 sec)
mysql>
我實際上在運行5.0.67 MySQL的Windows窗口上獲得858147.13。 – itsmatt 2009-05-22 15:34:06