当前位置: 代码迷 >> Oracle管理 >> update 语句 Oracle 9i
  详细解决方案

update 语句 Oracle 9i

热度:549   发布时间:2016-04-24 05:33:39.0
求助update 语句 Oracle 9i
表A 表B  

表A.bm = 表B.bm


现在要更新 表 A.zt = '1' 条件是 where 表A.bm = 表B.bm and 表A.zt='0' and 表B.cd='1'

我写的语句是 update (select * from A,B where A.bm=B.bm and A.zt='0' and B.cd='1') set zt = '1'


结果报错 

ORA-01779 : cannot modify a column which maps to a non key-preserved talbe

------解决方案--------------------
SQL code
update a set zt='1'where exists(select 1 from A,B where A.bm=B.bm and A.zt='0' and B.cd='1')
------解决方案--------------------
SQL code
--修改下update a set zt='1'where exists(select 1 from B where A.bm=B.bm and A.zt='0' and B.cd='1')
------解决方案--------------------
SQL code
update A  set zt = '1'where A.zt='0' and exists (select * from B where  A.bm=B.bm and  B.cd='1')
------解决方案--------------------
打慢了点……
------解决方案--------------------
SQL code
update a set zt='1'where exists(select 1 from B where A.bm=B.bm and A.zt='0' and B.cd='1')
  相关解决方案