Oracle will you really use the ltrim/rtrim function ?, Ltrimrtrim
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.
------- Remove spaces on both sides, left space, right space -------- select trim ('x-rapido ') name from dual; returns 'x-rapido 'select ltrim ('x-rapido') name from dual; returns 'x-rapido 'select rtrim ('x-rapido') name from dual; returns ''x-rapido ''select trim (null) name from dual; returns 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.