加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle trim函数去空格

发布时间:2020-12-12 16:08:07 所属栏目:百科 来源:网络整理
导读:TRIM Syntax 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 or trim_source is a character literal,then you must enclose it in sin

TRIM

Syntax


Description of the illustration trim.gif

Purpose

TRIMenables you to trim leading or trailing characters (or both) from a character string. Iftrim_characterortrim_sourceis a character literal,then you must enclose it in single quotes.

  • If you specifyLEADING,then Oracle Database removes any leading characters equal totrim_character.

  • If you specifyTRAILING,then Oracle removes any trailing characters equal totrim_character.

  • If you specifyBOTHor none of the three,then Oracle removes leading and trailing characters equal totrim_character.

  • If you do not specifytrim_character,then the default value is a blank space.

  • If you specify onlytrim_source,then Oracle removes leading and trailing blank spaces.

  • The function returns a value with datatypeVARCHAR2. The maximum length of the value is the length oftrim_source.

  • If eithertrim_sourceortrim_characteris null,then theTRIMfunction returns null.

Bothtrim_characterandtrim_sourcecan be any of the datatypesCHAR,VARCHAR2,NCHAR,NVARCHAR2,CLOB,orNCLOB. The string returned is ofVARCHAR2datatype iftrim_sourceis a character datatype and a LOB iftrim_sourceis 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 thehrschema:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读