开发者

Need help with OracleDB SQL Developer Regular Expression Query

开发者 https://www.devze.com 2023-03-10 00:47 出处:网络
When I let this Query run in my Oracle SQL Developer 1.5.3 select COLUMNNAME , REPLACE( COLUMNNAME, \'BEFORESTRING\', \'AFTERSTRING\' )

When I let this Query run in my Oracle SQL Developer 1.5.3

select 
  COLUMNNAME , 
  REPLACE( COLUMNNAME, 'BEFORESTRING', 'AFTERSTRING' ) 
    as COLUMNNAME
from 
  TABLENAME
;

This ain't working. Does anyone know what's wr开发者_StackOverflow社区ong with the Query? Or maybe the Oracle DB Developer Tool has a bug?

Update: I want to change the table not only print out a regex match.


Try:

update tablename
set columnname =  REPLACE( COLUMNNAME, 'BEFORESTRING', 'AFTERSTRING' ) ;

That will change all rows unless you add a WHERE clause. If there is a lot of data this would be more efficient:

update tablename
set columnname =  REPLACE( COLUMNNAME, 'BEFORESTRING', 'AFTERSTRING' ) 
where columnname like '%BEFORESTRING%';
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号