【发布时间】:2020-08-31 13:54:42
【问题描述】:
今天我正在尝试根据id键更新jsonb数组的多个值。
我在“people”表中有列 uniqueid 和 jsarray。
例如从人中选择*
1, [{"id": 1101, "val": "testing1", "valuom": "", "description": "Desc_test_1"},
{"id": 1105, "val": "testing2", "valuom": "", "description": "Desc_test_2"},
{"i d": 1108, "val": "testing2", "valuom": "", "description": "Desc_test_3"}]
我需要根据id key更新Description、val和valuom的值。
例如更新 id= 1101 和 uniqueid=1 的 jsarray 列; 需要 o/p 为:
1 , [{"id":1101,"val":"testing5","valuom":"test5", "description":"Desc_test_5"},
{"id":1105,"val":"testing2","valuom":"","description":"Desc_test_2"} ,
{"id":1108,"val":"testing2","valuom":"","description":"Desc_test_3"}];
【问题讨论】:
-
需要更新数组中的特定元素强烈表明对数据模型进行非规范化是错误的决定
标签: json postgresql jsonb postgresql-11