TRIM
Description of the illustration trim.gif
Purpose
TRIM
enables you to trim leading or trailing characters (or both) from a character string. Iftrim_character
ortrim_source
is a character literal,then you must enclose it in single quotes.
-
If you specify
LEADING
,then Oracle Database removes any leading characters equal totrim_character
. -
If you specify
TRAILING
,then Oracle removes any trailing characters equal totrim_character
. -
If you specify
BOTH
or none of the three,then Oracle removes leading and trailing characters equal totrim_character
. -
If you do not specify
trim_character
,then the default value is a blank space. -
If you specify only
trim_source
,then Oracle removes leading and trailing blank spaces. -
The function returns a value with datatype
VARCHAR2
. The maximum length of the value is the length oftrim_source
. -
If either
trim_source
ortrim_character
is null,then theTRIM
function returns null.
Bothtrim_character
andtrim_source
can be any of the datatypesCHAR
,VARCHAR2
,NCHAR
,NVARCHAR2
,CLOB
,orNCLOB
. The string returned is ofVARCHAR2
datatype iftrim_source
is a character datatype and a LOB iftrim_source
is a LOB datatype. The return string is in the same character set astrim_source
.
Examples
This example trims leading zeroes from the hire date of the employees in thehr
schema:
SELECT employee_id,TO_CHAR(TRIM(LEADING 0 FROM hire_date)) FROM employees WHERE department_id = 60; EMPLOYEE_ID TO_CHAR(T ----------- --------- 103 3-JAN-90 104 21-MAY-91 105 25-JUN-97 106 5-FEB-98 107 7-FEB-99
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions199.htm#i79689
原文地址:https://www.jb51.cc/oracle/213110.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。