Common Data Types in PostgreSQL

From the PostgreSQL Advanced Features cheat sheet ยท PostgreSQL Data Types ยท verified Jul 2026

Common Data Types

Frequently used PostgreSQL data types

sql
-- Numeric types
INTEGER              -- 4-byte integer
BIGINT               -- 8-byte integer  
SERIAL               -- Auto-incrementing integer
NUMERIC(10,2)        -- Exact decimal
REAL / FLOAT         -- Floating point

-- String types
VARCHAR(255)         -- Variable length
TEXT                 -- Unlimited length
CHAR(10)            -- Fixed length

-- Date/Time types
DATE                -- Date only
TIME                -- Time only
TIMESTAMP           -- Date and time
TIMESTAMPTZ         -- With timezone
INTERVAL            -- Time duration

-- Boolean
BOOLEAN             -- TRUE/FALSE/NULL

-- DETAILED_TAB:
-- Type casting examples
SELECT 
  '123'::INTEGER,                    -- Cast to integer
  '2024-01-01'::DATE,               -- Cast to date
  1::BOOLEAN,                        -- 1 becomes TRUE
  CAST('123.45' AS NUMERIC),        -- SQL standard casting
  '1 hour 30 minutes'::INTERVAL     -- Interval type
๐ŸŸข Essential - Know your data types for efficient storage
๐Ÿ’ก Use TEXT instead of VARCHAR when length is unknown
๐Ÿ“Œ SERIAL is PostgreSQL's AUTO_INCREMENT
โšก TIMESTAMPTZ is preferred over TIMESTAMP
๐Ÿ”— Related: pg_typeof() to check data types
datatypesbasics

Continue with PostgreSQL Advanced Features

Save the full cheat sheet or work through every related task.

More PostgreSQL tasks

Back to the full PostgreSQL Advanced Features cheat sheet