oracle 更新替换一个字段里面的指定字符串
update 表名 set 要更新的字段=replace(要更新的字段,'要替换的字符串','替换后字符串') where +条件oracle 判断字段中是否包含指定的字符select * from表 where instr(','||判断的字段||',',',指定的值,')>0mybatis :select * from表 where instr(','||判断的字段||',',conca
update 表名 set 要更新的字段=replace(要更新的字段,'要替换的字符串','替换后字符串') where +条件
oracle 判断字段中是否包含指定的字符
select * from 表 where instr(','||判断的字段||',',',指定的值,')>0
mybatis :
select * from 表 where instr(','||判断的字段||',',concat(concat(',', #{userId}), ',')) >0
oracle replace的用法
今天往Oracle 中导入数据时,有一个列导入的数据应该时‘2011-10-11’ 的格式,结果导入的数据为 ‘2011/10/11’格式的,5000多条记录要一条条改基本不可能。 后来想到了replace这个函数,具体用法如下:
update 表1 t set t.列1=replace((select 列1from 表1 a where a.主键列=t.主键列) , '/' , '-' ) 解决了我们问题。
replace 函数用法如下:
replace('将要更改的字符串','被替换掉的字符串','替换字符串')
例:select replace ('111222333444','222','888') from dual;
输出为 '111888333444'
更多推荐
所有评论(0)