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
Last updated: 25th January 2021
First published: 16th August 2018
First published: 16th August 2018