MySQL Decimal

The decimal type stores an exact value, which makes it appropriate for storing currency, unlike the float and double types.

Unlike integer types, the storage requirements vary, with the value being stored within the database in binary format.

Definition

When defining a decimal, one specifies the number of digits in total (including before and after the decimal place), followed by the number of digits you wish to store after the decimal place. For example, To store a range of -999.99 to 999.99, you would use the following definition.

DECIMAL(5,2)

The maximum number of digits that can be stored is 65.

References

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites. More info.