Oracle will you really use the ltrim/rtrim function?

Source: Internet
Author: User
The common usage is to remove spaces. How many people do not know that they can actually remove spaces? It has the ltrim () and ltrim (x, y) Methods ------- to remove spaces on both sides, and to leave null.

The common usage is to remove spaces. How many people do not know that they can actually remove spaces? It has the ltrim () and ltrim (x, y) Methods ------- to remove spaces on both sides, and to leave null.

The common usage is to remove spaces. How many people do not know that they can actually remove spaces? It has the ltrim () and ltrim (x, y) methods.

------- Go to the two sides of the space, go to the left space, go to the right space --------
Select trim ('x-rapido ') name from dual; 'X-rapido' is returned'
Select ltrim ('x-rapido ') name from dual; 'X-rapido' is returned'
Select rtrim ('x-rapido ') name from dual; returns ''x-rapido''
Select trim (null) name from dual; return null

Ltrim (x, y) syntax

The ltrim (x, y) function intercepts the characters in x one by one based on the characters in y, and runs them from the left. As long as some characters in y are met, the characters in x will be truncated, the Function Command ends only when y is not included in the x character.

Select ltrim ('abcababababe ',' AB ') word from dual;

Result: cdabababe

Select ltrim ('aaaaa', 'A') word from dual;

Result: null is null.

Select ltrim ('20140901', '20160901') nums from dual;

Result: 224323

Select ltrim ('20140901', '20160901') nums from dual;

Result: 4323

Select ltrim ('20140901', '20160901') nums from dual;

Result: 224323

Select ltrim ('20140901', '20160901') nums from dual;

Result: 200111000991110224323

Select ltrim ('20140901', '20160901') nums from dual;

Result: 2100111000991110224323

Note: Oracle is case sensitive.

Select ltrim ('abcdab', 'B') word from dual;

Result: abcdab

As for the rtrim function, like ltrim, one starts from the left and the other starts from the right.

The string truncation function is different from the substr function, because one is a specified character and the other is a specified subscript.

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.