一、需求

postgresql 数据库,需要将某些表中的json字段的数据进行替换。

二、做法

 思路:将json字段转为text,然后调用replace函数后,将text再转为json

update tableName set columnName=regexp_replace(columnName::text, '原内容', '修改内容', 'g')::json where 条件;

   

  以上的 regexp_replace 函数也可以切换成 replace ,如下:

update tableName set columnName = replace(columnName,'原内容','修改内容')  where columnName like '%billy%';

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-09
  • 2023-03-16
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案