A detailed explanation of Oracle's translate function usage

Source: Internet
Author: User
Tags empty translate function

TRANSLATE (' char ', ' from_string ', ' to_string ')

Translate returns a string that replaces each character in the from_string with the corresponding character in to_string.

Translate is a superset of the functionality provided by replace. If the from_string is longer than to_string, the extra characters in from_string that are not in to_string are removed from char because they do not have corresponding substitution characters. The to_string cannot be empty. Oracle interprets an empty string as null, and if any argument in translate is null, the result is null.

As an example

Select Translate (' 123abc ', ' 2dc ', ' 4e ') from dual;

Because the position of from_string and To_string is one by one corresponding, 2 corresponds to 4,d e,c no corresponding value, so C should be deleted.

So the example of the word character 2 will be replaced by 4,

D because there is no in the string, so do not replace,

C will be deleted in the string because there is no corresponding substitution character

So it can be concluded that the result is

143ab

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

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.