2013-08-21 23 views

回答

1

要做到这一点,您可以使用字符函数如substr()replace()

或正则表达式的功能 - regexp_replace()的实例。

SQL> with t1(col) as(
    2 select 'TEMPORARY-2 TIME ECS BOUND -04-Insuficient Balance' 
    3  from dual 
    4 ) 
    5 select concat(substr(col, 1, 11), ' X')    as res_1 
    6  , regexp_replace(col, '^(\w+-\d+)(.*)', '\1 X') as res_2 
    7 from t1 
    8 ; 

结果:

RES_1   RES_2 
------------- ------------- 
TEMPORARY-2 X TEMPORARY-2 X 

所以你update声明可能是这样的:

update your_table t 
    set t.col_name = regexp_replace(col_name, '^(\w+-\d+)(.*)', '\1 X') 
-- where clause if needed.