SQL Keywords

SQL DOUBLE

What is the SQL DOUBLE data type?

DOUBLE (or DOUBLE PRECISION) stores approximate numeric values using double-precision floating-point.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL DOUBLE: MySQL, PostgreSQL, SQL Server, Oracle, SQLite, MariaDB, Snowflake, BigQuery

SQL DOUBLE Full Explanation

DOUBLE, formally defined in the SQL standard as DOUBLE PRECISION, is an approximate numeric data type that uses IEEE-754 64-bit floating-point representation. It can hold very large or very small numbers with roughly 15-17 decimal digits of precision and an exponent range of about 10^-308 to 10^308. Because it is approximate, values are rounded to the nearest representable binary fraction, which can introduce small errors in arithmetic and comparisons.Most vendors expose the type under slightly different names:- MySQL, MariaDB: DOUBLE, DOUBLE PRECISION (synonyms)- PostgreSQL: DOUBLE PRECISION- SQL Server: FLOAT(53) (53 signifies 53-bit binary precision)- Oracle: BINARY_DOUBLE- SQLite: REAL (an alias using 8-byte floats)Unlike exact types such as DECIMAL or NUMERIC, DOUBLE should not be used for money, accounting, or other situations where every fraction of a unit must be preserved. It shines in scientific computing, analytics, statistical calculations, machine-learning pipelines, and anywhere a large dynamic range is valued over absolute exactness.DOUBLE occupies 8 bytes on disk and in memory. Arithmetic operations are usually hardware-accelerated, producing fast calculations. Most dialects allow CAST or implicit conversion between DOUBLE and other numeric types, although down-casting can lose precision.

SQL DOUBLE Syntax

column_name DOUBLE;
-- or, in standard form
column_name DOUBLE PRECISION;

SQL DOUBLE Parameters

Example Queries Using SQL DOUBLE

-- 1. Creating a table with DOUBLE values
CREATE TABLE sensor_readings (
  id INT PRIMARY KEY,
  temperature DOUBLE,
  humidity DOUBLE
);

-- 2. Inserting and selecting DOUBLE data
INSERT INTO sensor_readings (id, temperature, humidity)
VALUES (1, 23.456789, 0.458734);

SELECT id,
       temperature * 9/5 + 32 AS temp_fahrenheit
FROM sensor_readings;

-- 3. Casting an INT to DOUBLE for division
SELECT 5 / 2 AS int_division,
       5 / CAST(2 AS DOUBLE) AS float_division;

Expected Output Using SQL DOUBLE

  • Queries return 8-byte floating-point numbers
  • Calculations may show rounding (e
  • g
  • , 5 / 2 as 2
  • 5 when cast to DOUBLE)

Use Cases with SQL DOUBLE

  • Storing scientific sensor data where values span many orders of magnitude
  • Performing statistical aggregates like standard deviation or correlation
  • Machine learning feature engineering that involves continuous variables
  • Simulation or modeling workloads where speed outweighs exactness

Common Mistakes with SQL DOUBLE

  • Using DOUBLE for financial or accounting totals and encountering rounding errors
  • Expecting exact equality comparisons (0.1 + 0.2 = 0.3 may be false)
  • Forgetting to CAST integers to DOUBLE, leading to unintended integer division
  • Assuming all dialects treat DOUBLE and FLOAT identically; precision differs

Related Topics

FLOAT, REAL, DECIMAL, NUMERIC, CAST, ROUND

First Introduced In

SQL-92

Frequently Asked Questions

When should I use SQL DOUBLE instead of DECIMAL?

Use DOUBLE for scientific, statistical, or ML workloads that need a vast numeric range and can tolerate rounding. Use DECIMAL for exact monetary or inventory counts.

How many digits of precision does DOUBLE provide?

Approximately 15-17 decimal digits. Beyond that range values are rounded.

Is DOUBLE the same as FLOAT?

Not exactly. FLOAT is a generic term that each vendor maps to a specific precision. In most systems, FLOAT without length defaults to the same 8-byte format as DOUBLE, but this is not guaranteed.

How do I avoid equality errors with DOUBLE?

Compare with a tolerance (epsilon) instead of exact equality, e.g., WHERE ABS(a - b) < 1e-9;

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!