delete_element() function

The delete_element() function deletes an element from an array.

Syntax

The syntax for the delete_element() function supports deleting by name or by index:
array = delete_element(array input, int index);
array = delete_element(array input, varchar name);
array = delete_element(array input, nvarchar name);

The input value specifies the array that contains the element to delete.

The index value specifies the index of the element to delete from the array.

The name value specifies the name of the element to delete from the array.

Returns

The function deletes the array element.

Example

In the following example, an updated array (without the deleted element) is returned:
select delete_element(col2,1)from array_t;
 delete_element 
----------------
 ARR
(1 row)
You can view the contents of the array by using the following query:
select array_combine(col2,'|') from array_t;
 array_combine 
---------------
 23
(1 row)