AnalyticDB for PostgreSQL is compatible with the array functions and operators of PostgreSQL. This topic describes the array functions and operators that are supported by AnalyticDB for PostgreSQL and provides examples on how to use the array functions and operators.
For information about the array functions and operators of PostgreSQL, see Array Functions and Operators.
Array operators
Overview
Array operators such as || are used to perform operations on data of the ARRAY type. You can use the operators to perform operations and calculations on array expressions and return the corresponding results.
Operators
Operator | Description | Example | Sample result |
| Checks whether two arrays are equal. |
|
|
| Checks whether two arrays are not equal. |
|
|
| Checks whether the array to the left of the operator is less than the array to the right of the operator. |
|
|
| Checks whether the array to the left of the operator is greater than the array to the right of the operator. |
|
|
| Checks whether the array to the left of the operator is less than or equal to the array to the right of the operator. |
|
|
| Checks whether the array to the left of the operator is greater than or equal to the array to the right of the operator. |
|
|
| Checks whether the array to the left of the operator contains all elements of the array to the right of the operator. |
|
|
| Checks whether all elements of the array to the left of the operator are contained in the array to the right of the operator. |
|
|
| Checks whether two arrays overlap (have elements in common). |
|
|
| Concatenates two arrays. |
|
|
| Concatenates a one-dimensional array and a multidimensional array. |
|
|
| Sequentially concatenates an element and an array. |
|
|
| Sequentially concatenates an array and an element. |
|
|
Array functions
Overview
Array functions are used to operate on and manage arrays. You can use array functions to perform operations such as concatenating, appending, and deleting arrays to improve programming efficiency.
Functions
Function | Data type of the return value | Description | Example | Sample result |
|
| Appends an element to the end of an array. |
|
|
|
| Concatenates two arrays. |
|
|
|
| Returns the number of dimensions of an array. |
|
|
|
| Returns the text representation of the dimensions of an array. |
|
|
|
| Returns an array that is initialized based on the specified value and dimensions and has an optional lower bound (starting index) other than 1. |
|
|
|
| Returns the length of the dimension of the requested array. |
|
|
|
| Returns the lower bound of the dimension of the requested array. |
|
|
|
| Returns the subscript of the first occurrence of the second argument in the array specified by the first argument, starting at the first element of the array or the position specified by the third argument. This function is supported only for one-dimensional arrays. |
|
|
|
| Returns an array of subscripts of all occurrences of the second argument in the array specified by the first argument. This function is supported only for one-dimensional arrays. |
|
|
|
| Appends an element to the beginning of an array. |
|
|
|
| Removes all elements that are equal to a specific value from an array. This function is supported only for one-dimensional arrays. |
|
|
|
| Replaces the array elements that are equal to a specific value with a new value. |
|
|
|
| Concatenates array elements by using the specified delimiter and an optional null string. |
|
|
|
| Returns the upper bound of the dimension of the requested array. |
|
|
|
| Returns the total number of elements in an array. If an array is empty, this function returns 0. |
|
|
|
| Splits a string into array elements by using the specified delimiter and an optional null string. |
|
|
|
| Expands an array into a set of rows. |
| (2 lines) |
|
| Expands multiple arrays into a set of rows. The arrays can be of different data types. This function takes effect only when included in the |
| (3 lines) |