临时记录,具体可参考:PostgreSQL小总结
string 类型
参考自:PostgreSQL 常用函数
SELECT replace('abcdefabcdef', 'cd', 'XX')
但是如果类型为 JSON,下面这种执行,就不支持了。
1 | HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
UPDATE t_sc_feature_template_rule_copy2 SET rule_json_data=replace(rule_json_data,'store.active=true','store.active=true AND store.if_create_sc=1')
json 类型
表结构 json 类型
解释一下这个SQL:
1 | UPDATE t_sc_feature_template_rule_copy2 |
1、::text
把字段转为 text 类型,使用 replace 函数进行替换。
2、::json
替换完成,因为 replace 函数返回是文本类型,所以要再转为 json
转义符
2021-12-28 16:19:33
1 | -- [3] 转义符。在要替换的字符串前面加大写的 E,在内容中'单引号前面加 \ 反斜杠 |