TRIM returns a VARCHAR2 string with either the leading, trailing, or both the leading and trailing characters char trimmed from source.

TRIM([LEADING] [TRAILING] [BOTH] char FROM SOURCE)

IF you specify TRAILING then the trailing characters that match char will be trimmed.

Specifying BOTH will trim from both ends of the string.

If you do not provide a trim character, Oracle defaults to a blank space.

If you only specify the source argument, Oracle will remove the trailing and leading blank spaces from the source argument.

Example:

SELECT TRIM(‘ Too many spaces ‘) as RESULT FROM DUAL;

RESULT
——————
Too many spaces

Trim – Oracle SQL Function
Tagged on: