How to replace specific values in a oracle database column?

schar picture schar · Aug 9, 2010 · Viewed 423.4k times · Source

I am looking to replace values in a particular column. For example the following column values

column name
----------
Test1
Test2
Test3
Test12

should be (replacing est1 with rest1)

column name
----------
Trest1
Test2
Test3
Trest12

Answer

OMG Ponies picture OMG Ponies · Aug 9, 2010

Use REPLACE:

SELECT REPLACE(t.column, 'est1', 'rest1')
  FROM MY_TABLE t

If you want to update the values in the table, use:

UPDATE MY_TABLE t
   SET column = REPLACE(t.column, 'est1', 'rest1')