ARRAY REPLACE Function

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PostgreSQL ARRAY_REPLACE() function

ARRAY_REPLACE() function

This function is used to replace each array element equal to the given value with a new value.

Syntax :

array_replace(anyarray, anyelement, anyelement)

Return Type :

anyarray

PostgreSQL Version : 9.3

Example : PostgreSQL ARRAY_REPLACE() function

SELECT array_replace(ARRAY[1,2,5,4], 5, 3);

Output :

 array_replace
---------------
 {1,2,3,4}
(1 row)