description |
---|
Removes leading, trailing, or both spaces or characters from a string. |
- trim_expression: The characters to trim.
- expression: The expression to be trimmed.
Examples
{% code title="TRIM example" %}
SELECT TRIM(' pancake ')
-- pancake
{% endcode %}
{% code title="TRIM example" %}
SELECT TRIM(leading 'pan' from 'pancake')
-- cake
{% endcode %}
{% code title="TRIM example" %}
SELECT TRIM(trailing 'cake' from 'pancake')
-- pan
{% endcode %}
{% code title="TRIM example" %}
SELECT TRIM(both 'pan' from 'pancake pan')
-- cake
{% endcode %}
{% code title="TRIM example" %}
SELECT TRIM('pan' from 'pancake pan')
-- cake
{% endcode %}
{% code title="TRIM example" %}
SELECT TRIM('abnp' from 'pancake pan')
-- cake
{% endcode %}
If you do not specify a keyword before trim_expression
, it defaults to BOTH. If you do not specify trim_expression
, it defaults to a space. Organizations using Oracle will always receive a NULL
return if this function is used with an empty string.