What is the difference between REPLACE and TRANSLATE Functions in oracle database?
meda Changed status to publish 07/03/2022
Translate lets you character by character substitute or one-to-one substitutions whereas REPLACE is used to substitute single character by word.
its syntax is :- Translate (‘str’,’source’,’target’)
REPLACE (‘str’,’source’,’target’)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Example: F:\>cd F:\app\dell\virtual\product\12.2.0\dbhome_1\bin F:\app\dell\virtual\product\12.2.0\dbhome_1\bin>sqlplus/nolog SQL*Plus: Release 12.2.0.1.0 Production on Mon Feb 28 03:04:20 2022 Copyright (c) 1982, 2016, Oracle. All rights reserved. SQL> conn sys/orcl@orcl as sysdba Connected. SQL> select translate( 'welecome' , 'ec' , 'ab' ) from dual; TRANSLAT -------- walaboma SQL> select replace ( 'welecome' , 'come' , 'test' ) from dual; REPLACE ( -------- weletest |
Meri Edited answer 28/02/2022