Search code examples
sqlpostgresqlpostgresql-11

How can I replace the 'S for a 's in postgresql?


I have a table with large amount of 'S wrongly added and I want to replace it for 's:

I have tried with replace(field, ''S', ''s') but obviously doesn't accept it for the ', I also tried with the $$'$$ but still doesn't work.

The current version of PostgreSQL is 11 I have look into different threads and tried the solution there but didn't recognize i.e.

Replace apostrophe in string


Solution

  • The quote is the escape character for quotes as well. So you need one more quote for each string: replace(field, '''S', '''s')