schar schar - 6 months ago 15
SQL Question

How to replace specific values in a oracle database column?

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

Use REPLACE:

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

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

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