double precision
Learning Focus
Use this lesson to choose PostgreSQL double precision when you need floating point and more precision than real.
double precision Overview
- Storage: 8 bytes
- Approximate floating point
- Best for: scientific computations, measurements, analytics
Example
CREATE TABLE geo_points (
point_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
latitude double precision NOT NULL,
longitude double precision NOT NULL
);
Best Practices
- Prefer
double precisionoverrealfor most floating-point needs. - Avoid floats for exact values (use
numeric).