0
我有一个文本列,它包含一个非常长的json值 - 实际上是HTML代码。在Postgresql中编辑文本值
{"first_key" : "a very long html", "second_key" : "another very long html"}
如何轻松删除second_key及其值?
我有一个文本列,它包含一个非常长的json值 - 实际上是HTML代码。在Postgresql中编辑文本值
{"first_key" : "a very long html", "second_key" : "another very long html"}
如何轻松删除second_key及其值?
你可以使用regex_replace
,并希望第二HTML不包含}
字符:
update MY_TABLE set text_column = regex_replace(text_column, ', "second_key": ".*\}"', '')
where my_column_id = '<whatever>';
你必须调整你的正则表达式来完成这项工作。您可以通过使用相同的表达式执行select
来测试它,以查看您得到的结果。
PostgreSQL版本? –