postgresql - replace all instances of a string within text field

后端 未结 4 2194
时光取名叫无心
时光取名叫无心 2020-11-28 18:57

In postgresql, how do I replace all instances of a string within a database column?

Say I want to replace all instances of cat with dog, fo

4条回答
  •  再見小時候
    2020-11-28 19:29

    Here is an example that replaces all instances of 1 or more white space characters in a column with an underscore using regular expression -

    select distinct on (pd)
    regexp_replace(rndc.pd, '\\s+', '_','g') as pd
    from rndc14_ndc_mstr rndc;
    

提交回复
热议问题