storing money in decimal fields in MySQL

I haven’t found a lot of advice about what precision values to use for storing money in decimal fields.  Here’s what I calculated.  The scale is going to be 2 for US currency which requires 1 byte of storage.

  • precision 4, scale 2 = 2 bytes of storage, 99.99 to -99.99
  • precision 6, scale 2 = 3 bytes of storage, 9999.99 to -9999.99
  • precision 8, scale 2 = 4 bytes of storage, 999999.99 to -999999.99 (I’ve tended to suggest this as a starting point)
  • precision 11, scale 2 = 5 bytes
  • precision 13, scale 2 = 6 bytes
  • precision 15, scale 2 = 7 bytes
  • precision 17, scale 2 = 8 bytes

Leave a Reply

Your email address will not be published. Required fields are marked *