Dev G Dev G - 6 months ago 59
SQL Question

Oracle: Replace first character to other character

I have a table in oracle in which we have one column having data as

, means first alphabet always
and followed by numeric. I want to replace all such instances with
that will become

So if already there is a value called BH45678 in that column don't update.

Only where find B followed by numeric need updates.

vkp vkp

Get the rows which have B followed by digits using regexp_like. Then use replace to replace B with BH for those rows.

select replace(col,'B','BH')
from tablename
where regexp_like(col,'^B\d+$')