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

前端 未结 21 2180
孤独总比滥情好
孤独总比滥情好 2020-11-22 15:37

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 documenta

21条回答
  •  执笔经年
    2020-11-22 16:38

    UPDATE test
    SET data = data::jsonb - 'a' || '{"a":5}'::jsonb
    WHERE data->>'b' = '2'
    

    This seems to be working on PostgreSQL 9.5

提交回复
热议问题