postgresql – replace all instances of a string within text field

You want to use postgresql’s replace function:

replace(string text, from text, to text)

for instance :

UPDATE <table> SET <field> = replace(<field>, 'cat', 'dog')

Be aware, though, that this will be a string-to-string replacement, so ‘category’ will become ‘dogegory’. the regexp_replace function may help you define a stricter match pattern for what you want to replace.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)