PostgreSQL
数组数据类型
postgres=# create table arr(id int[],"name" char[]);
CREATE TABLE
postgres=# insert into arr values(array[1,2,3,4,5],array['a','b','c','d']);
INSERT 0 1
postgres=# select * from arr;
id | name
-------------+-----------
{1,2,3,4,5} | {a,b,c,d}
(1 row)
postgres=# select unnest(id) id ,unnest("name") "name" from arr;
id | name
----+------
1 | a
2 | b
3 | c
4 | d
5 |
(5 rows)
JSON 数据类型
postgres=# create table arrj(id json, "name" json);
CREATE TABLE
postgres=# insert into arrj values(array_to_json('{1,2,3,4,5}'::int[]),array_to_json('{"a","b","c","d"}'::char[]));
INSERT 0 1
postgres=# select * from arrj;
id | name
-------------+-------------------
[1,2,3,4,5] | ["a","b","c","d"]
(1 row)
postgres=# select json_array_elements_text(id) id ,json_array_elements_text(name) "name" from arrj;
id | name
----+------
1 | a
2 | b
3 | c
4 | d
5 |
(5 rows)