Data Types
6 min read Quiz at the end
PostgreSQL supports rich types: INTEGER, TEXT, BOOLEAN, TIMESTAMPTZ, UUID, JSONB, and arrays. Always use TIMESTAMPTZ for dates to store time in UTC. TEXT is preferred over VARCHAR for most string columns.
Common PostgreSQL Data Types Type Example INTEGER / BIGINT 42 NUMERIC(10,2) 9999.99 VARCHAR(255) 'Alice' TEXT long strings BOOLEAN TRUE / FALSE DATE 2024-01-15 TIMESTAMP 2024-01-15 10:30:00 UUID gen_random_uuid() JSONB {"key":"value"} ARRAY ARRAY[1,2,3]
Topic Quiz · 5 questions
Test your understanding before moving on
1. Which type stores timezone-aware dates and times?
A. TIMESTAMP
B. DATE
C. TIMESTAMPTZ
D. DATETIME
💡 TIMESTAMPTZ stores timestamp with timezone — always preferred over TIMESTAMP.
2. Which type stores unlimited text?
A. VARCHAR(255)
B. CHAR
C. TEXT
D. STRING
💡 TEXT in PostgreSQL stores strings of unlimited length.
3. What is JSONB?
A. Binary-encoded JSON
B. JSON with brackets
C. A JSON function
D. JSON Basic
💡 JSONB stores JSON in a decomposed binary format that supports indexing.
4. Which numeric type has exact precision?
A. FLOAT
B. DOUBLE
C. NUMERIC
D. REAL
💡 NUMERIC(precision, scale) stores exact decimal values — ideal for money.
5. Which type auto-increments as a primary key?
A. AUTO_INT
B. IDENTITY
C. SERIAL
D. BIGSERIAL only
💡 SERIAL is shorthand for a sequence-backed auto-incrementing integer.
Submit answers