array_remove()

A function for removing elements from an array

array_remove() is a system function for removeing all elements matching the specified value from an array.

array_remove() was added in PostgreSQL 9.3.

Usage

array_remove ( anyarray, anyelement ) → anyarray

The value specified for removal may also be NULL.

Change history

Examples

Basic execution example for array_remove():

postgres=# SELECT array_remove(ARRAY['foo','bar','baz','bar'], 'bar');
 array_remove
--------------
 {foo,baz}
(1 row)

NULL value can of course also be removed:

postgres=# SELECT array_remove(ARRAY['foo',NULL,'baz'], NULL);
 array_remove
--------------
 {foo,baz}
(1 row)

Categories

Arrays, System function

See also

array_replace()