replacing jsonb field value

Поиск
Список
Период
Сортировка
От john.tiger
Тема replacing jsonb field value
Дата
Msg-id 5569260A.4080407@gmail.com
обсуждение исходный текст
Ответы Re: replacing jsonb field value
Список pgsql-general
using 9.4.2

suppose we have
create table test (id serial primary key, data jsonb);
insert into test (data) values ({"a":1, "b":2})

want to replace "b" with 3

okay, we are retrieving entire record
res = select * from test where data ->> b = 2

newrec = res
newrec["b" = 3

delete from test where data ->> b= 2
insert into test (data) values (newrec)

is this the best way until upsert arrives ?



В списке pgsql-general по дате отправления:

Предыдущее
От: Daniel Begin
Дата:
Сообщение: Re: Planner cost adjustments
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Re: 9.4.1 -> 9.4.2 problem: could not access status of transaction 1