ORA-01779問題的解決

來源:互聯網
上載者:User
昨天幫一個師弟看一個ORACLE觸發器T的問題,這個觸發器建在視圖V上,當使用者往視圖裡插記錄的時候就自動插到視圖的組成表裡。但是每次插入總提示,ORA-01779 cannot modify a column which maps to a non key-preserved table。而怪異的是,有一個視圖V2和V的構成方式一摸一樣,但是它的觸發器T2就沒問題。在網上找了很多文章,絕大部分原因都是插入的基本表記錄不唯一,我檢查了觸發器內容和基本表的keys,都沒問題。

到第二天的時候突然看到一個文章的原因解釋:

view的更改是有限制的

General Rule
Any INSERT, UPDATE, or DELETE operation on a join view can modify only one underlying base table at a time.

UPDATE Rule
All updatable columns of a join view must map to columns of a key-preserved table. If the view is defined with the WITH CHECK OPTION clause, then all join columns and all columns of repeated tables are non-updatable.

DELETE Rule
Rows from a join view can be deleted as long as there is exactly one key-preserved table in the join. If the view is defined with the WITH CHECK OPTION clause and the key preserved table is repeated, then the rows cannot be deleted from the view.

INSERT Rule
An INSERT statement must not explicitly or implicitly refer to the columns of a non-key preserved table. If the join view is defined with the WITH CHECK OPTION clause, INSERT statements are not permitted.

(http://www.itpub.net/225291.html)

再檢查了觸發器,發現事件那塊只關聯了UPDATE,其他都沒關聯,粗心啊。全部關聯上就好了。

看來觸發器的幾個選項一定要好好檢查啊。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.