ARRAY_INSERT

functionsupportedCore SQL functions

docs.snowflake.com ↗

Semi-structured and structured data functions

Returns an array containing all elements from the source array as well as the new element.

Syntax

ARRAY_INSERT( <array> , <pos> , <new_element> )

Parameters

NameRequiredDescription
arrayrequiredThe source array.
posrequiredA (zero-based) position in the source array. The new element is inserted at this position. The original element from this position (if any) and all subsequent elements (if any) are shifted by one position to the right in the resulting array (i.e. inserting at position 0 has the same effect as using ARRAY_PREPEND). A negative position is interpreted as an index from the back of the array (e.g. -1 results in insertion before the last element in the array).
new_elementrequiredThe element to be inserted. The new element is located at position pos. The relative order of the other elements from the source array is preserved.

Returns

The data type of the returned value is ARRAY.

Usage notes

Referenced by