Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 940 Bytes

array.md

File metadata and controls

38 lines (27 loc) · 940 Bytes

Array value Expression

Array expression can be created using the ARRAY keyword followed by a list of expression between [ and ].

SELECT ARRAY[1, 2, 3];
SELECT ARRAY[ARRAY[1, 2, 3], ARRAY[4, 5, 6], ARRAY[7, 8, 9]];

Or you can write the list of expressions directly with [ and ]

SELECT [1, 2, 3];
SELECT [[1, 2, 3], [4, 5, 6], [7, 8, 9]];

Slice Expression

Slice expression can be used to return a slice from array from [start:end.

SELECT [1, 2, 3][1:2];
SELECT [[1, 2, 3], [4, 5, 6], [7, 8, 9]][1:2];

Slice expression can be used also with 1 as start range to return a slice from array from 1 to the end.

SELECT [1, 2, 3][:2];
SELECT [[1, 2, 3], [4, 5, 6], [7, 8, 9]][:3];

Slice expression can be used also with start only range to return a slice from array from start to length of array.

SELECT [1, 2, 3][1:];
SELECT [[1, 2, 3], [4, 5, 6], [7, 8, 9]][2:];