我在
之类的表的列中有一个字符串值entity_id: long
oldest_item_id: integer
newest_item_id: integer
total_signals: integer
我想用另一个字符串值'ABCDEF'替换第四个值,可以通过单个更新还是通过PL / SQL程序来实现?
答案 0 :(得分:1)
这里是一个选择:
SQL> with test (id, col) as
2 (select 1, '001|3880000005376|Personal ID| ||15-MAY-2006' from dual union all
3 select 2, '002|3880000005376|Personal ID|XXX||15-MAY-2007' from dual
4 )
5 select
6 id,
7 regexp_replace(col, '[^|]+', 'NEW STRING', 1, 4) result
8 from test;
ID RESULT
---------- ------------------------------------------------------------
1 001|3880000005376|Personal ID|NEW STRING||15-MAY-2006
2 002|3880000005376|Personal ID|NEW STRING||15-MAY-2007
SQL>
它将'[^|]+'
模式的第4次出现替换为NEW STRING
值。