我有一些來自服務器的值需要存儲在我的數據庫中。我不是MySQL專家,但我對基本輸入/輸出瞭解得非常好。現在我正試圖弄清楚在存儲下面的小數時應該使用什麼長度。MySQL:十進制數據類型的大小
tax_rate [DECIMAL ?,?]: value(0.014840000000)
units [DECIMAL ?,?]: value(1.00)
initial_charge [DECIMAL ?,?]: value(2.5110)
charge [DECIMAL ?,?]: value(2.8967)
link_tax [DECIMAL ?,?]: value(0.385652)
exempt [DECIMAL ?,?]: value(0.0000)
tax [DECIMAL ?,?]: value(0.042986)
base_price [DECIMAL ?,?]: value(41.8500)
我希望有人可以建議我需要使用這些值的正確數據長度如何解釋爲什麼他們選擇的值。或者,也可以鏈接到一篇深入解釋MySQL小數的文章。
任何幫助,將不勝感激。
謝謝!
------- 編輯 --------
閱讀MySQL的文檔後,這是我已經解決了以下小數長度爲:
tax_rate [DECIMAL 15,12]: value(0.014840000000) ? max(999.999999999999)
units [DECIMAL 6,2]: value(1.00) ? max(9999.99)
initial_charge [DECIMAL 9,4]: value(2.5110) ? max(99999.9999)
charge [DECIMAL 9,4]: value(2.8967) ? max(99999.9999)
link_tax [DECIMAL 9,6]: value(0.385652) ? max(999.999999)
exempt [DECIMAL 9,4]: value(0.0000) ? max(9999.9999)
tax [DECIMAL 10,6]: value(0.042986) ? max(999999.999999)
base_price [DECIMAL 10,4]: value(41.8500) ? max(999999.9999)
深入:官方文檔在http://dev.mysql.com/doc/refman/5.0/en/fixed-point-types.html – Amadan