postgresql - 更新 JSONb 值
问题描述
我想更新 PostgreSQL 表中的 JSONb 值,这里是他的原型:
{
key1: {
key2: {
key3: value
...
}
...
}
...
}
我想更新key1->key2->>key3
。
解决方案
您可以jsonb_set()
为此使用:
update the_table
set the_column = jsonb_set(the_column, '{key1,key2}', '{"key3": "new_value"}')
where the_pk_column = 42;
推荐阅读
- c++ - 如何在 C++ 中的 Windows 中显示一个名称为参数的窗口
- c# - 在 VCode 上编译 C# 和在 MAC 上编译终端有什么区别
- ionic-framework - Fastlane, ionic 5 & cordova, 如何添加参数
- python - 从 google.oauth2.Credentials 获取访问令牌
- javascript - EJS - 包含括号不起作用
- python - 使用 Python Selenium 切换到 iframe 时出错
- swift - 在 Bazel 中集成 AudioKit (Swift CocoaPod)
- c++ - 如何更改结构中变量的值?
- r - 自动填充 r 中的列
- vue.js - Vue Jest 错误找不到带有 node_modules 路径的模块,解析器未定义