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
- Select LTrim (' Abcddee ',' abc ') from dual;
----------Output Results
Ddee
The results should all be known ... , there are also
[SQL]View PlainCopy
- 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
- Select LTrim (' Abcccabddee ',' abc ') from dual;
----------Output Results
Ddee
[SQL]View PlainCopy
- 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
- 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