MySQL Float vs Double vs Decimal

June 03, 2025

  • Approximate numeric type.
  • Use when precision is not critical.
  • 4 bytes of storage, ~7 digits precision.
CREATE TABLE float_example (
  value FLOAT
);

INSERT INTO float_example (value) VALUES (123.456789);

SELECT * FROM float_example;
-- Output: 123.4568

  • Also approximate, but more precise than FLOAT.
  • 8 bytes of storage, ~15–17 digits precision.
CREATE TABLE double_example (
  value DOUBLE
);

INSERT INTO double_example (value) VALUES (123456789.123456789);

SELECT * FROM double_example;
-- Output: 123456789.12345679

  • Exact numeric type (not approximate).
  • Used for financial calculations requiring precision.
  • Syntax: DECIMAL(M,D), max total digits 65, max decimal digits 30.
CREATE TABLE decimal_example (
  value DECIMAL(65,30)
);

INSERT INTO decimal_example (value) VALUES (12345678901234567890.123456789012345678901234567890);

SELECT * FROM decimal_example;
-- Output: Exact value with high precision

Here's a comparison of the maximum length and precision for each numeric type:

Type Max Precision (Digits) Max Value (Approx) Exact? Storage
FLOAT ~7 digits ±3.402823466E+38 4 bytes
DOUBLE ~15–17 digits ±1.7976931348623157E+308 8 bytes
DECIMAL Up to 65 digits Defined by user (DECIMAL(65,30), etc.) Varies (depends on precision)