当我更新一个视图的时候,遇到这个错误:ORA-01779: 无法修改与非键值保存表对应的列01779, 00000, "cannot modify a column which maps to a non key-preserved table"
// *Cause: An attempt was made to insert or update columns of a join view which
// map to a non-key-preserved table.
// *Action: Modify the underlying base tables directly.可以来模拟这个错误:SQL> desc gw2
Name Type Nullable Default Comments
------- ------- -------- ------- --------
SID INTEGER Y
OLD_SID INTEGER Y SQL> select * from gw1;
ID SID
--------------------------------------- ---------------------------------------
1 1
2 2
3 3
4 4
SQL> select * from gw2;
SID OLD_SID
--------------------------------------- ---------------------------------------
1 11
2 22
3 33
SQL> update (select gw1.sid,gw2.old_sid from gw1,gw2 where gw1.sid=gw2.sid) s set s.sid=s.old_sid;
update (select gw1.sid,gw2.old_sid from gw1,gw2 where gw1.sid=gw2.sid) s set s.sid=s.old_sid
ORA-01779: 无法修改与非键值保存表对应的列这是因为,不能保证gw1中的一个sid对应一个唯一的gw2表的sid,也就是说gw2的sid不能保证唯一,解决的方法就是将gw2的sid加上unique约束。SQL> alter table gw2 modify sid unique;
Table altered
SQL> update (select gw1.sid,gw2.old_sid from gw1,gw2 where gw1.sid=gw2.sid) s set s.sid=s.old_sid;
3 rows updated这样就可以了。
相关阅读:GoldenGate不使用数据泵完成Oracle-Oracle的双向复制 http://www.linuxidc.com/Linux/2013-10/92020.htm使用GoldenGate的数据泵进行Oracle-Oracle的单向复制 http://www.linuxidc.com/Linux/2013-10/92019.htm如何对 Oracle 数据泵(expdp/impdp) 进行 debug http://www.linuxidc.com/Linux/2013-06/85232.htmOracle 数据库导出数据泵(EXPDP)文件存放的位置 http://www.linuxidc.com/Linux/2013-05/83774.htmOracle 10g 数据泵分区表的导出 http://www.linuxidc.com/Linux/2012-07/66620.htm更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12expdp ORA-39070: Unable to open the log fileORA-02283: 无法变更启动序列号相关资讯 ORA-01779 本文评论 查看全部评论 (0)