Oracle9i SQL Reference Release 2 (9.2) Part Number A96540-02 |
|
|
View PDF |
trim::=
TRIM
enables you to trim leading or trailing characters (or both) from a character string. If trim_character
or trim_source
is a character literal, then you must enclose it in single quotes.
LEADING
, then Oracle removes any leading characters equal to trim_character
.TRAILING
, then Oracle removes any trailing characters equal to trim_character
.BOTH
or none of the three, then Oracle removes leading and trailing characters equal to trim_character
.trim_character
, then the default value is a blank space.trim_source
, then Oracle removes leading and trailing blank spaces.VARCHAR2
. The maximum length of the value is the length of trim_source
.trim_source
or trim_character
is null, then the TRIM
function returns null.Both trim_character
and trim_source
can be any of the datatypes CHAR
, VARCHAR2
, NCHAR
, NVARCHAR2
, CLOB
, or NCLOB
. The string returned is of VARCHAR2
datatype and is in the same character set as trim_source
.
This example trims leading and trailing zeroes from a number:
SELECT TRIM (0 FROM 0009872348900) "TRIM Example" FROM DUAL; TRIM Example ------------ 98723489