2013-08-21 25 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.