PostgreSQL RANGE Types
PostgreSQL RANGE Types is a SQL data type in the PostgreSQL Specific category. PostgreSQL range types represent intervals (date ranges, price ranges, etc.) with built-in operators. The syntax is INT4RANGE / TSRANGE / DATERANGE / NUMRANGE. It returns range value. A typical example: CREATE TABLE meetings ( room_id INT, during TSRANGE, EXCLUDE USING GIST (room_id WITH =, during WITH &&) ); INSERT INTO meetings VALUES (1, '["2026-06-06 09:00", "2026-06-06 10:00")'); -- [ means inclusive, ) means exclusive -- Range operators: SELECT * FROM meetings WHERE during @> '2026-06-06 09:30'::timestamp; -- Contains this time? SELECT * FROM meetings WHERE during && '["2026-06-06 09:30", "2026-06-06 10:30")'::tsrange; -- Overlaps with this range? SELECT upper(during) - lower(during)… A close relative is SERIAL, which postgreSQL auto-increment type. Creates an INTEGER column with a sequence. Equivalent to AUTO_INCREMENT in MySQL. A close relative is RETURNING, which postgreSQL extension that returns values from INSERT/UPDATE/DELETE statements (like OUTPUT in SQL Server).