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
Oracle provides you with the TRANSLATE() function that has similar functionality as the REPLACE() function. However, the TRANSLATE() function provides single-character, one-to-one substitution, while the REPLACE() function allows you to substitute one string for another.
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')
If you need to update the value in a particular 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With