postgresql_16:3.5.17 Range Types
PostgreSQL 16 > The SQL Language > Data Types > Range Types
Range types are data types representing a range of values of some element type (called the range's *subtype*). For instance, ranges of timestamp might be used to represent the ranges of time that a meeting room is reserved. In this case the data type is tsrange (short for “timestamp range”), and timestamp is the subtype. The subtype must have a total order so that it is well-defined whether element values are within, before, or after a range of values.
Range types are useful because they represent many element values in a single range value, and because concepts such as overlapping ranges can be expressed clearly. The use of time and date ranges for scheduling purposes is the clearest example; but price ranges, measurement ranges from an instrument, and so forth can also be useful.
Every range type has a corresponding multirange type. A multirange is an ordered list of non-contiguous, non-empty, non-null ranges. Most range operators also work on multiranges, and they have a few functions of their own.
Subsections
- postgresql_16:3.5.17.1 Built-in Range and Multirange Types
- postgresql_16:3.5.17.2 Examples
- postgresql_16:3.5.17.3 Inclusive and Exclusive Bounds
- postgresql_16:3.5.17.4 Infinite (Unbounded) Ranges
- postgresql_16:3.5.17.5 Range Input/Output
- postgresql_16:3.5.17.6 Constructing Ranges and Multiranges
- postgresql_16:3.5.17.7 Discrete Range Types
- postgresql_16:3.5.17.8 Defining New Range Types
- postgresql_16:3.5.17.9 Indexing
- postgresql_16:3.5.17.10 Constraints on Ranges