title: MySQL: Size of decimal data type
body: <p>I have a few values that come in from a server that need to be stored in my database.  I'm not a MySQL expert, but I understand it well enough for basic input/output. Right now I am trying to determine the length I should be using when storing the following decimals.</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>I'm hoping someone could suggest the correct size I need to use for these values AS WELL explain why they chose the values. Or maybe link to an article that explains MySQL decimals in depth.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thank you!</p>
  
  <p>-------<strong>Edit</strong>--------</p>
  
  <p>After reading the MySQL docs, there is a very good explanation to determining the size of the decimal type. These are the sizes I have set for my use case:</p>
  
  <pre><code>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)
  </code></pre>