![](/img/trans.png)
[英]how update dynamically attribute in jsonb data column with postgres
[英]how update attribute in jsonb data column with postgres
嗨,我在postgres的jsonb專欄中有此結構
{
"cronograma_actividades": {
"section_template_id": 5,
"ciclos": [
{
"ciclo_verano": {
"nro_semanas_max": 9,
"programas": [
{
"pregrado": {
"modalidades": [
{
"type": "presencial",
"codigo_formula": "FOR2234",
"unidades": [
{
"nro": 1,
"titulo": "Unidad aprendi",
"logro": "Logro de una unidad es texto",
"semanas": [
]
},
{}
]
},
]
}
因此,我如何使用postgres更新字段codigo_formula,此列是jsonb類型,我找到json_object_set_path,但是我不知道如何訪問深樹
問候
假設包含jsonb的列稱為“ testcol”,則可以執行以下操作:
update t_test set testcol = jsonb_set(testcol, '{cronograma_actividades,ciclos,0,ciclo_verano,programas,0,pregrado,modalidades,0}', jsonb('{"cordigo_formula":"new value"}'), false);
0值表示數組中的位置。 實際上在postgresql中有一篇關於json(b)的令人印象深刻的帖子,您可能想在這里閱讀 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.