oracle trim函数去空格
博客专区 > Oscarfff 的博客 > 博客详情
oracle trim函数去空格
Oscarfff 发表于1年前
oracle trim函数去空格
  • 发表于 1年前
  • 阅读 38
  • 收藏 0
  • 点赞 0
  • 评论 0

标题:腾讯云 新注册用户域名抢购1元起>>>   

TRIM

Syntax

Description of trim.gif follows
Description of the illustration trim.gif
 

Purpose

TRIM enables you to trim leading or trailing characters (or both) from a character string. If trim_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 to trim_character.

  • If you specify TRAILING, then Oracle removes any trailing characters equal to trim_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 or trim_character is null, then the TRIM function returns null.

Both trim_character and trim_source can be any of the datatypes CHARVARCHAR2NCHARNVARCHAR2CLOB, orNCLOB. The string returned is of VARCHAR2 datatype if trim_source is a character datatype and a LOB iftrim_source is a LOB datatype. The return string is in the same character set as trim_source.

Examples

This example trims leading zeroes from the hire date of the employees in the hr 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

共有 人打赏支持
粉丝 70
博文 802
码字总数 96913
×
Oscarfff
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: