oracle中如何替换字符串的前三个字符 [英] How to replace first three characters of a string in oracle
本文介绍了oracle中如何替换字符串的前三个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在oracle中替换一个字符串的前三个字符.假设我有 100 条员工 ID 记录,我需要替换 100 条记录中 30 到 50 条记录的前三个字符.
How to replace first three characters of a string in oracle. Lets say i have 100 records of employee id, i need to replace first three characters of records between 30 to 50 out of 100.
- 输入:111234,111235,111236,111237
- 输出:222234,222235,222236,222237(替换并更新)
推荐答案
假设您想用 abc
替换第 30 到 50 行(按某些条件排序)的前 3 个字符,则:
Assuming you want to replace the first 3 characters with abc
for the 30th to 50th rows (ordered by some criteria) then:
SELECT CASE
WHEN ROWNUM BETWEEN 30 AND 50
THEN 'abc' || SUBSTR( your_column, 4 )
ELSE your_column
END AS replaced_value
FROM (
SELECT *
FROM your_table
ORDER BY <some_criteria>
)
这篇关于oracle中如何替换字符串的前三个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文