PostgreSQL/Array/Concatenate Array

Материал из SQL эксперт
Перейти к: навигация, поиск

array_dims(1 || ARRAY[2,3])

   <source lang="sql">

postgres=# SELECT array_dims(1 || ARRAY[2,3]);

array_dims

[0:2]

(1 row) postgres=#

      </source>
   
  


array_dims(ARRAY[1,2] || 3)

   <source lang="sql">

postgres=# SELECT array_dims(ARRAY[1,2] || 3);

array_dims

[1:3]

(1 row) postgres=#

      </source>
   
  


array_dims(ARRAY[[1,2],[3,4]] || ARRAY[[5,6],[7,8],[9,0]])

   <source lang="sql">

postgres=# SELECT array_dims(ARRAY[[1,2],[3,4]] || ARRAY[[5,6],[7,8],[9,0]]);

array_dims

[1:5][1:2]

(1 row) postgres=#

      </source>
   
  


array_dims(ARRAY[1,2] || ARRAY[3,4,5])

   <source lang="sql">

postgres=# SELECT array_dims(ARRAY[1,2] || ARRAY[3,4,5]);

array_dims

[1:5]

(1 row) postgres=#

      </source>
   
  


array_dims(ARRAY[1,2] || ARRAY[[3,4],[5,6]])

   <source lang="sql">


postgres=# SELECT array_dims(ARRAY[1,2] || ARRAY[[3,4],[5,6]]);

array_dims

[0:2][1:2]

(1 row) postgres=#


      </source>
   
  


Concatenate two arrays

   <source lang="sql">

postgres=# postgres=# postgres=# SELECT ARRAY[1,2] || ARRAY[3,4];

?column?

{1,2,3,4}

(1 row) postgres=#

      </source>
   
  


Concatenate two dimensional arrays

   <source lang="sql">

postgres=# SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];

           ?column?

[0:2][1:2]={{5,6},{1,2},{3,4}}

(1 row) postgres=#

      </source>