AnalyticDB for PostgreSQL is compatible with the range functions and operators of PostgreSQL. This topic describes the range functions and operators that are supported by AnalyticDB for PostgreSQL and provides examples on how to use the range functions and operators.
For information about the range functions and operators of PostgreSQL, see Range Functions and Operators.
Range operators
Overview
Range operators, such as @>
and &&
, are used to perform operations on range expressions and return the corresponding results.
Usage
You can use range operators to compare, limit, and define ranges.
Operators
Operator | Description | Example | Sample result |
| Checks whether two ranges are equal. |
|
|
| Checks whether two ranges are not equal. |
|
|
| Checks whether the range to the left of the operator is less than the range to the right of the operator. |
|
|
| Checks whether the range to the left of the operator is greater than the range to the right of the operator. |
|
|
| Checks whether the range to the left of the operator is less than or equal to the range to the right of the operator. |
|
|
| Checks whether the range to the left of the operator is greater than or equal to the range to the right of the operator. |
|
|
| Checks whether the range to the left of the operator contains the range to the right of the operator. |
|
|
| Checks whether the range to the left of the operator contains the element to the right of the operator. |
|
|
| Checks whether the range to the left of the operator falls within the range to the right of the operator. |
|
|
| Checks whether the element to the left of the operator falls within the range to the right of the operator. |
|
|
| Checks whether two ranges overlap (have points in common). |
|
|
| Checks whether the range to the left of the operator is strictly less than the range to the right of the operator with no overlap. |
|
|
| Checks whether the range to the right of the operator is strictly less than the range to the left of the operator with no overlap. |
|
|
| Checks whether the range to the left of the operator does not exceed the upper bound of the range to the right of the operator. |
|
|
| Checks whether the range to the right of the operator does not exceed the upper bound of the range to the left of the operator. |
|
|
| Checks whether two ranges are adjacent. |
|
|
| Returns the union of two ranges. |
|
|
| Returns the intersection of two ranges. |
|
|
| Subtracts the range to the right of the operator from the range to the left of the operator. |
|
|
Range functions
Overview
Range functions are used to define ranges, limit ranges, or check whether a value falls within a specific range.
Usage
You can use range functions to define the upper and lower bounds of a range.
Functions
Function | Data type of the return value | Description | Example | Sample result |
| Data type of the elements of the range | Returns the lower bound of a range. |
|
|
| Data type of the elements of the range | Returns the upper bound of a range. |
|
|
|
| Checks whether a range is empty. |
|
|
|
| Checks whether the lower bound of a range is inclusive. |
|
|
|
| Checks whether the upper bound of a range is inclusive. |
|
|
|
| Checks whether the lower bound of a range is infinite. |
|
|
|
| Checks whether the upper bound of a range is infinite. |
|
|
|
| Returns the smallest range after merging two ranges. |
|
|