我有一些值来自需要存储在我的数据库中的服务器.我不是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)
我希望有人可以建议我需要使用这些值的正确尺寸AS WELL解释他们为什么选择这些值.或者链接到一篇深入解释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)