postgresql-json

Explanation of JSONB introduced by PostgreSQL

为君一笑 提交于 2019-11-26 04:03:35
问题 PostgreSQL just introduced JSONB and it\'s already trending on hacker news. It would be great if someone could explain how it\'s different from Hstore and JSON previously present in PostgreSQL. What are it\'s advantages and limitations and when should someone consider using it? 回答1: First, hstore is a contrib module, which only allows you to store key => value pairs, where keys and values can only be text s (however values can be sql NULL s too). Both json & jsonb allows you to store a valid

How do I modify fields inside the new PostgreSQL JSON datatype?

做~自己de王妃 提交于 2019-11-26 01:29:12
问题 With postgresql 9.3 I can SELECT specific fields of a JSON data type, but how do you modify them using UPDATE? I can\'t find any examples of this in the postgresql documentation, or anywhere online. I have tried the obvious: postgres=# create table test (data json); CREATE TABLE postgres=# insert into test (data) values (\'{\"a\":1,\"b\":2}\'); INSERT 0 1 postgres=# select data->\'a\' from test where data->>\'b\' = \'2\'; ?column? ---------- 1 (1 row) postgres=# update test set data->\'a\' =