In MySQL, DECIMAL(
and M
,D
)NUMERIC(
are the same, and both have a precision of exactly M
,D
)M
digits.
Leftover Digits Number of Bytes 0 0 1–2 1 3–4 2 5–6 3 7–9 4
For example,
a DECIMAL(18,9)
column has nine digits on either side of the decimal point, so the integer part and the fractional part each require 4 bytes.
A DECIMAL(20,6)
column has fourteen integer digits and six fractional digits.
The integer digits require four bytes for nine of the digits and 3 bytes for the remaining five digits.
The six fractional digits require 3 bytes.