ORA-01779: 無法修改與非索引值儲存表對應的列

來源:互聯網
上載者:User

當我更新一個視圖的時候,遇到這個錯誤: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的雙向複製

使用GoldenGate的資料泵進行Oracle-Oracle的單向複製

如何對 Oracle 資料泵(expdp/impdp) 進行 debug

Oracle 資料庫匯出資料泵(EXPDP)檔案存放的位置

Oracle 10g 資料泵分區表的匯出

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.