Array of arrays in PostgreSQL

前端 未结 3 854
一个人的身影
一个人的身影 2020-12-17 02:57

I\'m using the %% operator on PostgreSQL\'s hstore type which converts a hstore (key-value type effectively) into an array whose elements alternate {{key, value

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 03:46

    PostgreSQL support a multidimensional arrays instead - arrays are relative very special type in relational databases and it is little bit limited against general programming languages. If you need it, you can use a workaround with row arrays:

    postgres=# create table fx(a int[]);
    CREATE TABLE
    postgres=# insert into fx values(array[1,3,4]);
    INSERT 0 1
    postgres=# insert into fx values(array[6,7]);
    INSERT 0 1
    postgres=# select array_agg(row(a)) from fx;
                array_agg            
    ---------------------------------
     {"(\"{1,3,4}\")","(\"{6,7}\")"}
    (1 row)
    

提交回复
热议问题