首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

update 语句 Oracle 9i

2012-03-19 
求助update 语句Oracle 9i表A表B表A.bm 表B.bm现在要更新表 A.zt 1条件是where表A.bm 表B.bmand表A.

求助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') 

热点排行