Oracle Replace () function usage

Source: Internet
Author: User

Introduction to Usage

REPLACE (char, search_string [, replacement_string])

Char: String to wait for replacement

Search_string: Search for strings to replace

Replacement_string: Replacement string

If replacement_string is either default or null, then all occurrences of search_string in char will be removed

If search_string is null, then the result is Char

The code is as follows Copy Code

Select REPLACE (' JACK and Jue ', ' J ', ' BL ') "Changes" from DUAL;

Example 1

The format of ' 2011-10-11 ' in the database, the result imported data for ' 2011/10/11 '

The code is as follows Copy Code

Update table 1 T. column 1=replace (select column 1from table 1 A where a. primary key column =t. Primary key column), '/', '-' solves our problem.

Replace string-level substitution

Such as:

The code is as follows Copy Code
SELECT REPLACE (' ACCD ', ' CD ', ' EF ') from dual; --> AEFD

Translate character-level substitution

Such as:

The code is as follows Copy Code
Select Translate (' ACDD ', ' CD ', ' EF ') from dual; -->aeff

Separate detailed

Replace

Syntax: REPLACE (char,search_string[,replacement_string])

Explanation: In Replace, each search_string is replaced by replacement_string

The code is as follows Copy Code

Select replace (' ACDD ', ' CD ', ' EF ') from dual; --> AEFD

If replacement_string is null or NULL, then all search_string are removed

The code is as follows Copy Code

Select replace (' ACDD ', ' CD ', ') from dual; --> AD

If search_string is null, then return the original Char

The code is as follows Copy Code

Select replace (' ACDD ', ' EF ') from dual; -->acdd

Elect replace (' ACDD ', ', ', ') from dual; -->acdd

(is also a case of both empty)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.