Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does M,D mean in decimal(M,D) exactly?

Tags:

mysql

decimal

Does anyone know about this?

like image 355
user198729 Avatar asked Nov 30 '09 05:11

user198729


People also ask

What is Double M D?

M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits permitted by the hardware. A double-precision floating-point number is accurate to approximately 15 decimal places. DOUBLE( M , D ) is a nonstandard MySQL extension.

What is the size of decimal data type?

Range: The range of DECIMAL type is -10^38 +1 through 10^38 –1. The largest value is represented by DECIMAL(38, 0) . The most precise fractional value (between 0 and 1, or 0 and -1) is represented by DECIMAL(38, 38) , with 38 digits to the right of the decimal point.

What is decimal in database?

The decimal data type is an exact numeric data type defined by its precision (total number of digits) and scale (number of digits to the right of the decimal point).

What is decimal in MySQL?

In standard SQL, the syntax DECIMAL( M ) is equivalent to DECIMAL( M ,0) . Similarly, the syntax DECIMAL is equivalent to DECIMAL( M ,0) , where the implementation is permitted to decide the value of M . MySQL supports both of these variant forms of DECIMAL syntax. The default value of M is 10.


1 Answers

As the docs say:

M is the maximum number of digits (the precision). It has a range of 1 to 65. (Older versions of MySQL allowed a range of 1 to 254.)

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.

So M stands for Maximum (number of digits overall), D stands for Decimals (number of digits to the right of the decimal point).

like image 122
Alex Martelli Avatar answered Oct 05 '22 04:10

Alex Martelli