Data Type Picker

PostgreSQL

Categories

PostgresGUI

Numeric

Use integer for most things, numeric for money

numeric(p,s)variable

Money, financial calculations, anywhere you need exact decimal precision.


Range

up to 131,072 digits before decimal, 16,383 after

Performance

Slower than float/integer. Exact arithmetic avoids rounding errors.

Comparison

numeric vs real/double: numeric is exact, floats are approximate. Never use float for money. numeric(12,2) gives 10 digits before decimal and 2 after.

SQL Example
CREATE TABLE invoices (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  amount numeric(12,2) NOT NULL
);
PostgreSQL Numeric Types — integer, bigint, numeric, float | PostgresGUI