• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql
You are here: Home / Oracle / function / Oracle/SQL Replace Function

Oracle/SQL Replace Function

November 26, 2012 by techhoneyadmin

Oracle REPLACE FunctionOracle/SQL REPLACE Function is used to replace a sequence of characters within a string with another set of characters. Oracle REPLACE Function can be used to substitute a string, a single characters or NULL for a character or set of characters(string). Syntax and examples of SQL REPLACE STRING and SQL REPLACE TEXT are mentioned below.


Oracle/SQL REPLACE Function Syntax

SELECT REPLACE(string_1,string_to_replace[,replacement_string])
FROM table_name;

In the above Oracle REPLACE Function Syntax:-

  • string_1 is the string in which replacements will be made
  • string_to_replace is the string which will be replaced in string_1
  • replacement_string is an optional parameter, if present, then all the occurrences of string_to_replace in string_1will be replaced by replacement_string, if omitted, then all the occurrences of string_to_replace in string_1 will be omitted and the remaining part of string_1 will be returned.

Oracle/SQL REPLACE Function – Replacing with NULL Example

Oracle REPLACE Function is used with the SQL SELECT Statement.

Oracle REPLACE Function can take 2 or 3 arguments.

The first one is the string in which the replacements are to be done.

The second one is the string which is to be replaced.

The third (optional) one is the string which will replace the second string.

For example, the below Oracle REPLACE Function query returns replaces null at places where value is ‘T’.

SELECT REPLACE('Tech Honey', 'T') "PLSQL Replace Function"
FROM dual;

The above Oracle REPLACE Function query returns ‘ech Honey’.

Note: We have aliased REPLACE(‘Tech Honey’, ‘T’) as PLSQL Replace Function.


Oracle/SQL REPLACE Text Example

Oracle/SQL REPLACE TEXT queries can be written to replace a character in string with another string or character.

For example, the SQL REPLACE TEXT query below replaces ‘T’ with ‘t’.

SELECT REPLACE('Tech Honey', 'T','t') "SQL REPLACE TEXT"
FROM dual;

The above REPLACE SQL TEXT query returns ‘tech Honey’

Note:We have aliased SELECT REPLACE(‘Tech Honey’, ‘T’,’t’) as SQL REPLACE TEXT.


Oracle/SQL REPLACE String Example

SQL REPLACE String queries can be written to replace a string with another string or character.

For example, the SQL REPLACE String query below replaces ‘Tech’ with ‘t’.

SELECT REPLACE('Tech Honey', 'Tech','t') "SQL REPLACE String"
FROM dual;

The above REPLACE SQL STRING query returns ‘t Honey’
Note: We have aliased SELECT REPLACE(‘Tech Honey’, ‘Tech’,’t’) as SQL REPLACE String.


Filed Under: function Tagged With: how to use REPLACE Function in oracle database query, how to use REPLACE Function in oracle plsql, how to use REPLACE Function in oracle sql, REPLACE Function in oracle plsql, REPLACE Function in oracle sql, REPLACEPLSQL, syntax and example of REPLACE Function in oracle database query, syntax and example of REPLACE Function in oracle plsql, syntax and example of REPLACE Function in oracle sql, using REPLACE Function in oracle database query, using REPLACE Function in oracle plsql, using REPLACE Function in oracle sql

Copyright © 2023 · Parallax Pro on Genesis Framework · WordPress · Log in