且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

oracle中如何替换字符串的前三个字符

更新时间:2023-01-19 21:32:50

假设您想用 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>
)