Below is an alphabetical list of functions that we can use when working with arrays in PostgreSQL.
Function | Description |
---|---|
array_append() | Appends an element to the end of an array. |
array_cat() | Concatenates two arrays. |
array_dims() | Returns information about the dimensions in an array. |
array_fill() | Creates an array filled multiple instances of a given value. |
array_length() | Returns the length of the specified array dimension. |
array_lower() | Returns the lower bound of the specified array dimension. |
array_ndims() | Returns the number of dimensions of an array. |
array_position() | Returns the position of the first occurrence of a given value in an array. |
array_positions() | Returns the position of the all occurrences of a given value in an array. |
array_prepend() | Prepends an element to the start of an array. |
array_remove() | Removes elements from an array. |
array_replace() | Replaces a specified element (or elements) in an array with another element. |
array_sample() | Returns an array of a specified number of items randomly selected from the given array. |
array_shuffle() | Randomly shuffles the first dimension of a given array. |
array_to_string() | Converts an array to a string. |
array_upper() | Returns the upper bound of the specified array dimension. |
cardinality() | Returns the total number of elements in an array. This includes elements across all dimensions of the array. |
trim_array() | Trims a given number of elements from the end of an array. |
unnest() | Expands an array into a set of rows. |