The TRIM function in Oracle is used to remove spaces or specific characters at both ends of a string. The syntax is: TRIM([trim_character] FROM string). It can remove all spaces in a string (trim_character parameter is omitted), it can remove specified characters (specify trim_character parameter), or even remove multiple specified characters (specify multiple trim_character parameters). It should be noted that the TRIM function does not remove spaces in the middle of the string.
Usage of TRIM function in Oracle
TRIM function is used in Oracle to remove spaces or spaces at both ends of a string. Function for specifying characters. It uses the following syntax:
TRIM([trim_character] FROM string)
where:
How to use the TRIM function?
To use the TRIM function, simply pass the string you want to trim as a parameter. For example:
SELECT TRIM(' Hello, world! ') FROM dual;
This will return a trimmed string:
Hello, world!
Remove specific characters
The TRIM function can also remove specific characters from a string. To do this, specify the character to be removed in the trim_character parameter. For example:
SELECT TRIM('---Hello---' FROM '-') FROM dual;
This will return the trimmed string:
Hello
Using multiple trim_character
TRIM function can receive multiple trim_character as parameters , to remove multiple characters from a string. For example:
SELECT TRIM('##Hello!##' FROM '#!') FROM dual;
This will return the trimmed string:
Hello!
Note:
The above is the detailed content of How to use trim in oracle. For more information, please follow other related articles on the PHP Chinese website!