SQL Keywords

SQL FLOAT8

What is SQL FLOAT8?

FLOAT8 declares an 8-byte, double-precision floating-point data type used for approximate numeric storage.
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 FLOAT8: Supported: PostgreSQL, Amazon Redshift, Greenplum, DuckDB, YugabyteDB. Partially via synonym DOUBLE PRECISION: Snowflake, BigQuery. Not supported under this exact keyword in MySQL, SQL Server, Oracle, SQLite.

SQL FLOAT8 Full Explanation

FLOAT8 is an alias for DOUBLE PRECISION in PostgreSQL and several PostgreSQL-compatible systems. It stores 64-bit IEEE-754 floating-point numbers, offering roughly 15 decimal digits of precision and exponent range up to 1E308. Because it is an approximate numeric type, arithmetic can introduce rounding error and should not be used for money or other exact values. FLOAT8 columns default to accepting NaN and ±Infinity unless constrained. When casting, FLOAT8 converts compatible numeric or character input to double precision, truncating or rounding as needed. Storage size is a fixed 8 bytes. Performance is faster than arbitrary-precision NUMERIC but less precise. Choosing FLOAT8 over FLOAT4 avoids overflow and precision loss at the cost of twice the space. Not supported natively in many non-PostgreSQL databases, where the equivalent keyword is DOUBLE or DOUBLE PRECISION.

SQL FLOAT8 Syntax

-- Column definition
column_name FLOAT8 [DEFAULT expression] [NOT NULL];

-- Casting
SELECT CAST(value AS FLOAT8);
-- or
SELECT value::FLOAT8;

SQL FLOAT8 Parameters

Example Queries Using SQL FLOAT8

-- Create a table with a FLOAT8 column
CREATE TABLE sensor_readings (
  id SERIAL PRIMARY KEY,
  temperature_c FLOAT8 NOT NULL,
  recorded_at TIMESTAMPTZ DEFAULT NOW()
);

-- Insert data
INSERT INTO sensor_readings (temperature_c) VALUES (21.4567890123456);

-- Cast text to FLOAT8
SELECT '3.14159265358979'::FLOAT8 AS pi_value;

-- Mathematical calculation
SELECT AVG(temperature_c) FROM sensor_readings;

Expected Output Using SQL FLOAT8

  • The table is created with a double-precision column
  • Inserts succeed, the cast returns a FLOAT8 value of 3
  • 14159265358979, and AVG returns a double-precision result

Use Cases with SQL FLOAT8

  • Storing scientific measurements that can exceed FLOAT4 precision
  • Performing statistical calculations requiring large dynamic range
  • Aggregations where intermediate overflow is possible with smaller floats
  • Migrating data from systems that already use double precision

Common Mistakes with SQL FLOAT8

  • Assuming FLOAT8 is exact; rounding errors can occur
  • Using FLOAT8 for financial amounts instead of NUMERIC
  • Expecting identical binary results across platforms; representation may differ
  • Forgetting that comparisons on floating values can be unreliable with equality operators

Related Topics

DOUBLE PRECISION, FLOAT4, REAL, NUMERIC, DECIMAL, CAST, ALTER TABLE

First Introduced In

PostgreSQL 6.0

Frequently Asked Questions

What precision does FLOAT8 provide?

FLOAT8 offers roughly 15 decimal digits of precision and supports very large or small numbers up to about 1E308.

Is FLOAT8 suitable for storing money?

No. Because FLOAT8 is approximate, rounding errors can occur. Use NUMERIC or DECIMAL for currency.

How does FLOAT8 differ from FLOAT4?

FLOAT8 stores double the bytes and precision of FLOAT4, reducing overflow risk but consuming more space.

Which databases recognize the FLOAT8 keyword?

PostgreSQL and derivatives (Redshift, Greenplum, DuckDB) support FLOAT8. Other engines use the keyword DOUBLE or DOUBLE PRECISION instead.

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!