Search code examples
mysqldecimalvarchar

MySQL Column Type for Variable Length Decimal Numbers


I'm trying to find the best column type to use for numeric values of varying length both before and after the decimal place.

The DECIMAL type seems to only allow a fixed-length number with a fixed-length also after the decimal. I need something that preserves to exact precision numbers like:

  • 1.50
  • 222.05
  • 124.2584879775435298
  • 5344.87987797797979077

I can't find anything other than varchar that clearly accommodates this. Am I missing something?


Solution

  • Do you need these numbers for future numeric operations? If not, then you should be able to store the data as a variable length character string so VARCHAR could work.

    here this website may answer your questions:

    http://dev.mysql.com/doc/refman/5.6/en/numeric-types.html