是否可以在不创建函数且不使用任何服务器端编程语言的情况下转换 postgresql 9.4 jsonb 数据?
CREATE TABLE test (id SERIAL PRIMARY KEY,data JSONB);
INSERT INTO test(data) VALUES('{"a":1,"b":2}');
INSERT INTO test(data) VALUES('{"a":3,"b":4,"c":7}');
INSERT INTO test(data) VALUES('{"a":5,"b":5,"d":8}');
SELECT * FROM test;
id | data
----+-------------------------
1 | {"a": 1, "b": 2}
2 | {"a": 3, "b": 4, "c": 7}
3 | {"a": 5, "b": 5, "d": 8}
将其转换为:
{1:[1,2,null,null],2:[3,4,7,null],3:[5,5,null,8]}