有什么方法可以更新JSON列?
ALTER TABLE
managers
UPDATE
JSONExtractString(managers.extra_data, 'name') = JSONExtractString(other_table.extra_data, 'name')
WHERE 1
上面的查询不起作用,也找不到类似于jsonb_set
函数的东西
ALTER TABLE
managers
UPDATE
JSONExtractString(managers.extra_data, 'name') = JSONExtractString(other_table.extra_data, 'name')
WHERE 1
Query above does not work, also couldn't find something similar to jsonb_set
function like in psql
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以用
ether_table
作为源创建字典,然后使用jsonextractString(dictget('my_dict',managers.key),'name')
从dict读取每个特定键的数据。就您而言,无法理解如何在这两个表中加入行。
You can create dictionary with
other_table
as source and then useJSONExtractString(dictGet('my_dict', managers.key), 'name')
to read data from dict for each specific key.In your case there is no way to understand how to join rows in this two tables.
clickhouse 23.10 给我们新功能 jsonmergepatch ,这绝对可以帮助更新JSON字段。
更新一个密钥的值更新
一行的许多键
更新许多行,使用第二个表
注意:在这里您可以找到,如何更新非json字段。
让我们假设,您需要为所有经理更新名称。例如,您拥有具有这样的结构
id,new_value
的CSV文件。然后,您需要:注意:文件必须在clickhouse-server目录中,名为
user_files
注意:不建议更新Clickhouse中的所有表! 位置的过滤
Clickhouse 23.10 give us new function jsonMergePatch, that definitely can help updating json fields.
Updating value for one key
Updating many keys for one row
Updating many rows, using second table
NOTE: Here you can find, how to update non-json fields.
Let's assume, you need to update names for all managers. For example, you have csv-file with such structure
id,new_value
. Then, you need to:NOTE: File must be in clickhouse-server directory, named
user_files
NOTE: it's not recommended to update all table in clickhouse! You should have filter for where-closure.