Mac Ben - 11 months ago 28

SQL Question

I encountered many times this problem of decimal in MySQL !

When i put this type:

`DECIMAL(10,8)`

The maximum value allowed are:

`99.99999999`

It supposed to be:

`9999999999.99999999`

I want a maximum value of decimal with 8 digits after the point (.).

Answer

From the documentation:

The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments in MySQL 5.7 are as follows:

- M is the maximum number of digits (the precision). It has a range of 1 to 65.
- D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.

The first value is not the number of digits to the left of the decimal point, but the total number of digits.

That's why the value `9999999999.99999999`

with `DECIMAL(10, 8)`

is not possible: it is 18 digits long.