PostgreSQL array_remove() Function
The PostgreSQL array_remove()
function removes all specified elements from the specified array and returns the modified array.
array_remove()
Syntax
Here is the syntax of the PostgreSQL array_remove()
function:
array_remove(array, element) -> array
Parameters
array
-
Required. The array to remove the specified element from.
element
-
Required. The element to remove.
Return value
The PostgreSQL array_remove()
function returns an array from which the specified element is removed.
The type of the element to be removed must be the same as the data type of the array, otherwise the array_remove()
function will give an error message.
The array_remove()
function will return NULL
if the specified array is NULL
.
array_remove()
Examples
This example shows how to use the PostgreSQL array_remove()
function to remove 2
from {1, 1, 2, 1, 2, 1, 2}
.
SELECT array_remove(ARRAY[1, 1, 2, 1, 2, 1, 2], 2);
array_remove
--------------
{1,1,1,1}