当前位置: 代码迷 >> Oracle技术 >> ORACLE:update表的某一个字段所有后面加一个字符串
  详细解决方案

ORACLE:update表的某一个字段所有后面加一个字符串

热度:52   发布时间:2016-04-24 08:09:16.0
ORACLE:update表的某一个字段全部后面加一个字符串
主要列
yljgid        yljgdm
主键           要更新的目标字段

这是我的SQL语句
update tb_dic_hx_yljgzdb t set t.yljgdm=(select j.yljgdm||'360824' from tb_dic_hx_yljgzdb j
where t.yljgdm=j.yljgdm)
where t.yljgdm like 'PT%' and length(yljgdm)<14 and length(yljgdm)>8 

报错:ORA-00001 违反唯一约束性条件
------解决方案--------------------
把where 条件改一下,就行了!具体调整如下:
update tb_dic_hx_yljgzdb t set t.yljgdm=(select j.yljgdm
------解决方案--------------------
'360824' from tb_dic_hx_yljgzdb j
 where t.yljgdm=j.yljgdm AND t.yljgdm like 'PT%' and length(t.yljgdm)<14 and length(t.yljgdm)>8 )

------解决方案--------------------
update tb_dic_hx_yljgzdb t set t.yljgdm=t.yljgdm
------解决方案--------------------
'360824'  where t.yljgdm like 'PT%' and length(t.yljgdm)<14 and length(t.yljgdm)>8 
  相关解决方案