0

I have a jsonb column that stores values like this:

{"v":"0","c":"ACC",...}

I'd like to update some of the v values to 1

Is there any built-in function to do that in postgresql?

E: I'm using v9.6

Joshua Rajandiran
  • 2,788
  • 7
  • 26
  • 53

1 Answers1

1

With Postgresql 9.5

UPDATE test SET data = data - 'v' || '{"v":1}' WHERE data->>'c' = 'ACC';

OR

UPDATE test SET data = jsonb_set(data, '{v}', '1'::jsonb);
Andreea Craciun
  • 302
  • 1
  • 6