【发布时间】:2019-04-17 14:50:59
【问题描述】:
我在 PostgreSQL 中得到了以下jsonb 内容:
{
"segments": [
{
"type": "year",
"settings": [
{
"name": "length",
"value": "4"
}
]
},
{
"type": "month",
"settings": [
{
"name": "length",
"value": "2"
}
]
},
{
"type": "dayOfMonth",
"settings": [
{
"name": "length",
"value": "2"
}
]
},
{
"type": "autoIncrement",
"settings": [
{
"name": "scope",
"value": "plant"
},
{
"name": "period",
"value": "day"
},
{
"name": "length",
"value": "10"
},
{
"name": "paddingCharactor",
"value": "0"
}
]
}
]
}
我想在 segments -> type=autoIncrement -> settings -> period
中将期间从“day”更新为“forever”我试过jsonb_set并在拆分后手动合并数据,都失败了。
有更新值的想法吗?
【问题讨论】:
-
表名
serial_rules,字段名rule -
并不是说不能这样做,但是如果您有兴趣定期操作其更深层次的内容,我建议不要将您的数据作为 JSON 存储在数据库中。使用简单的关系表单独存储各个元素,这样更容易处理。
标签: sql json postgresql jsonb