0

我这里有问题。在我的数据库中,我在mobile_phone列中有值,628932323但我想更改使用的每一行62 to 0

old value : 628932323
new value : 08932323

有人可以帮我解决我的问题。谢谢

4

1 回答 1

1

如果您使用的是 oracle 10g 或更高版本,则可以使用 regexp_replace 函数http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions130.htm

select regexp_replace(your_column, '62([:digit:]*)', '0\2')
from your_table;

或者更老式的方式没有:

select case
         when your_column like '62%' then '0' || substr(your_column, 3)
       else
         your_column
       end
from your_table;

请注意电话号码字符串中的前导空格或其他字符。

于 2012-10-31T08:26:28.433 回答