First-class data types representing a continuous range of values (integers, dates, timestamps) with built-in operators for containment, overlap, and adjacency.
PostgreSQL types that represent an interval with a lower and upper bound: int4range, daterange, tsrange. Enable efficient storage and querying of temporal intervals. Useful for reservation systems and versioned records.
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | ✗ Not Supported | — | No range types. Use two columns (start_date, end_date) and enforce constraints manually or via triggers. |
| PostgreSQL | ✓ Supported | 9.2 | Built-in types: int4range, int8range, numrange, tsrange, tstzrange, daterange. Multirange types (int4multirange, etc.) added in PG 14. Operators: @> (contains), <@ (contained by), && (overlaps), << (strictly left of), >> (strictly right of), -|- (adjacent). GiST indexable. Boundary inclusivity is explicit: [1,5) vs (1,5]. |
| SQL Server | ✗ Not Supported | — | No range types. Temporal tables (2016+) handle system-time history but are not general-purpose range types. |
| Oracle | ✗ Not Supported | — | No range types. INTERVAL types exist but represent durations, not ranges. |
| SQLite | ✗ Not Supported | — | No range types. Use two columns. |
Unique to PostgreSQL. Range types are especially powerful in combination with exclusion constraints and GiST indexes — the canonical use case is a double-booking prevention system.
No range types. Use two columns (start_date, end_date) and enforce constraints manually or via triggers.
Built-in types: int4range, int8range, numrange, tsrange, tstzrange, daterange. Multirange types (int4multirange, etc.) added in PG 14. Operators: @> (contains), <@ (contained by), && (overlaps), << (strictly left of), >> (strictly right of), -|- (adjacent). GiST indexable. Boundary inclusivity is explicit: [1,5) vs (1,5].
No range types. Temporal tables (2016+) handle system-time history but are not general-purpose range types.
No range types. INTERVAL types exist but represent durations, not ranges.
No range types. Use two columns.