Reproduced Oracle LTrim () function usage

Source: Internet
Author: User
Tags rtrim truncated

In the previous article on the use of the two functions of Lpad and Rpad, the two other functions that today find the opposite meaning are LTrim () RTRIM ().

This time pick LTrim () This function to say:

The specific syntax format is as follows:

LTRIM (C1,[,C2])

"Feature" removes the string that appears to the left

"Parameter" C1 string, c2 append string, default to Space

"Return" character type

Let's take a look at a few examples:

[SQL]View PlainCopy
    1. Select LTrim (' Abcddee ',' abc ') from dual;

----------Output Results

Ddee

The results should all be known ... , there are also

[SQL]View PlainCopy
    1. Select LTrim (' Abcccabddee ',' abc ') from dual;

----------Output Results

Ddee

Maybe some people think the result should be "Ccabddee" is right, then look at the following

[SQL]View PlainCopy
    1. Select LTrim (' Abcccabddee ',' abc ') from dual;

----------Output Results

Ddee

[SQL]View PlainCopy
    1. Select LTrim (' Abcddabddee ',' abc ') from dual;

----------Output Results

Ddabddee

Why the second one is more than a D is not truncated ...

After reading the following statement should be clear!

[SQL]View PlainCopy
    1. Select LTrim (' Abdcdabddee ',' abc ') from dual;

----------Output Results

Dcdabddee
Finally, summarize

The LTRIM (C1,[,C2]) function is a truncated C1 character in C2 characters, and is executed from the left, and once the characters in C2 are encountered, the characters in the C1 are truncated, until the C1 character does not have a C2 character. RTRIM () is the same as LTrim (), except that it is executed from the right.

Note: LTRIM () function

"Similar" RTRIM () Delete the string that appears to the right

"Opposite" lpad () pastes characters on the left side of the column

RTRIM () function

"Similar" LTRIM () Delete the string that appears to the left

Rpad () Pastes the character to the right of the column

Reproduced Oracle LTrim () function usage

Related Article

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.