Oracle TRIM function are used to remove all specific characters either from the beginning, ending or both side of strings.
Note :- trim set should have only one character.
Syntax :
----------
TRIM( [ [ LEADING | TRAILING | BOTH ] trim_character FROM ] string )
LEADING :- Remove trim_character from the front of string.
TRAILING :- Remove trim_character from the end of string.
BOTH :- Remove trim_character from the both (start and end) side of string.
SQL> SELECT TRIM('K' FROM 'KINKGK') RESULT FROM DUAL;
RESU
----
INKG
SQL> SELECT TRIM( LEADING 'K' FROM 'KINKGK') RESULT FROM DUAL;
RESUL
-----
INKGK
SQL> SELECT TRIM( BOTH 'K' FROM 'KINKGK') RESULT FROM DUAL;
RESU
----
INKG
SQL> SELECT TRIM( TRAILING 'K' FROM 'KINKGK') RESULT FROM DUAL;
RESUL
-----
KINKG
SQL>
Note :- trim set should have only one character.
Syntax :
----------
TRIM( [ [ LEADING | TRAILING | BOTH ] trim_character FROM ] string )
LEADING :- Remove trim_character from the front of string.
TRAILING :- Remove trim_character from the end of string.
BOTH :- Remove trim_character from the both (start and end) side of string.
SQL> SELECT TRIM('K' FROM 'KINKGK') RESULT FROM DUAL;
RESU
----
INKG
SQL> SELECT TRIM( LEADING 'K' FROM 'KINKGK') RESULT FROM DUAL;
RESUL
-----
INKGK
SQL> SELECT TRIM( BOTH 'K' FROM 'KINKGK') RESULT FROM DUAL;
RESU
----
INKG
SQL> SELECT TRIM( TRAILING 'K' FROM 'KINKGK') RESULT FROM DUAL;
RESUL
-----
KINKG
SQL>