PostgreSQL 18 reference · Array Functions
PostgreSQL ARRAY_CAT() Function
Concatenate two arrays of the same element type into one new array. The || operator does the same thing.
PostgreSQL 18
Syntax
array_cat(array1, array2)
Parameters
| Parameter | Description |
|---|---|
array1, array2 |
Arrays of the same element type. |
Return value
A new array.
Examples
SELECT array_cat(ARRAY[1, 2], ARRAY[3, 4]) AS joined;
Output
joined
-----------
{1,2,3,4}
(1 row)Run this on your computer — see “Get Started” for setup.
SELECT array_cat(ARRAY[[1, 2]], ARRAY[[3, 4]]) AS two_rows;
Output
two_rows
---------------
{{1,2},{3,4}}
(1 row)Run this on your computer — see “Get Started” for setup.
Related
ARRAY_APPEND()· Add an element to the end of an array. array_prepend() adds to the start, and || joins arrays or elements.- SQL String Functions · tutorial