如何通过sql更新视图!

来源:互联网 发布:中国自大 知乎 编辑:程序博客网 时间:2024/06/05 17:58

有时候直接通过更新视图将会使得sql大大简化,但是直接更新会出现ORA-01779: cannot modify a column which maps to a non key-preserved table错误

解决方法:通过添加BYPASS_UJVC提示,示例如下:

 

update /*+ BYPASS_UJVC*/
(select b1.name, b1.id from (select 10001 kid from dual union select 10000 from dual) temp, b1
where b1.id = temp.kid)

set name=name||' '||id
where id=10000;