转自:http://www.jb51.net/article/53576.htm
实际例子如下:
update SYS_DICTIONARY_BAK set display_name = trim(display_name)
where table_name='T_GUARDIAN'
and column_name='zy'
;
引申:
如 trim('字符1' from '字符串2') ,字符1只能是单个字符。
1. trim()删除字符串两边的空格。
2. ltrim()删除字符串左边的空格。
3. rtrim()删除字符串右边的空格。
4. trim('字符1' from '字符串2') 分别从字符2串的两边开始,删除指定的字符1。
5. trim([leading | trailing | both] trim_char from string) 从字符串String中删除指定的字符trim_char。
leading:从字符串的头开始删除。
trailing:从字符串的尾部开始删除。
borth:从字符串的两边删除。
6. tim()只能删除半角空格。
For example:
trim(' tech ') would return 'tech';
trim(' ' from ' tech ') would return 'tech';
trim(leading '0' from '000123') would return '123';
trim(trailing '1' from 'Tech1') would return 'Tech';
trim(both '1' from '123Tech111') would return '23Tech';
说明:
其中SYS_DICTIONARY_BAK表定义为:
CREATE TABLE "SCOTT"."SYS_DICTIONARY_BAK"
( "PK_ID" NUMBER(10,0) NOT NULL ENABLE,
"TABLE_NAME" NVARCHAR2(100),
"COLUMN_NAME" NVARCHAR2(100),
"VALUE" NVARCHAR2(100),
"DISPLAY_NAME" NVARCHAR2(100),
"ORDERBY" NUMBER(10,0),
"MEMO" NVARCHAR2(512),
"CREATE_TIME" CHAR(19 CHAR),
"UPDATE_TIME" CHAR(19 CHAR),
"DR" NUMBER(3,0)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" ;
ALTER TABLE "SCOTT"."SYS_DICTIONARY_BAK" MODIFY ("PK_ID" NOT NULL ENABLE);