What are PostgreSQL data types
· Category: SQL & Databases
Short answer
PostgreSQL offers a rich set of built-in types beyond standard SQL, including arrays, JSONB, ranges, UUIDs, geometric types, and custom composite types.
How it works
Standard types like INTEGER, VARCHAR, and TIMESTAMP are available alongside specialized types. Arrays allow storing multi-value fields in a single column. Range types represent intervals with inclusive or exclusive bounds. Composite types let you define row-like structures. UUID provides globally unique identifiers.
Example
CREATE TABLE events (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tags TEXT[],
duration TSRANGE
);
Why it matters
Rich types reduce the need for external serialization and enable database-level validation and operations on complex data.r