How to replace specific values ​​in oracle database column?

I want to replace the values ​​in a specific 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 
+49
sql oracle replace
Aug 09 '10 at 18:47
source share
4 answers

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') 
+129
Aug 09 '10 at 18:49
source share

If you need to update the value in a specific table:

 UPDATE TABLE-NAME SET COLUMN-NAME = REPLACE(TABLE-NAME.COLUMN-NAME, 'STRING-TO-REPLACE', 'REPLACEMENT-STRING'); 

Where

  TABLE-NAME - The name of the table being updated COLUMN-NAME - The name of the column being updated STRING-TO-REPLACE - The value to replace REPLACEMENT-STRING - The replacement 
+16
Oct 22 '13 at 1:06 on
source share

Oracle has the concept of a schema name, so try using this

 update schemname.tablename t set t.columnname = replace(t.columnname, t.oldvalue, t.newvalue); 
-one
Jun 16 '16 at 16:56
source share

I am using Version 4.0.2.15 with Line 15.21

I needed this:

 UPDATE table_name SET column_name = REPLACE(column_name,"search str","replace str"); 

Putting t.column_name in the first argument of replace did not work.

-2
May 13 '16 at 1:55
source share



All Articles