如何允许在 Oracle 中更新视图的结果?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/763802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to permit update of a view's results in Oracle?
提问by lamcro
I understand that database views are read-only, or at least read-only by default.
我知道数据库视图是只读的,或者至少默认情况下是只读的。
Is it possible to enable the change of data brought by an oracle view?
是否可以启用oracle视图带来的数据变化?
Rephrasing:If I make a view of just one table, just to hide some columns, will changes to this data be updated on the table?
改写:如果我只查看一个表,只是为了隐藏一些列,对这些数据的更改会在表上更新吗?
回答by andri
Yes, Oracle views can be modified.
是的,可以修改 Oracle 视图。
There are, however, some restrictions:
但是,有一些限制:
- views that contain set operators, aggregates, GROUP BY, DISTINCT and joins (in general)are not modifiable
- only some join viewsare modifiable
回答by cagcowboy
I don't believe Oracle views are read only by default... a single table view should be updateable providing it doesn't contain multiple row operations like DISTINCT or GROUP BY. The user in question must have been granted UPDATE VIEW privs.
我不相信 Oracle 视图在默认情况下是只读的……如果单个表视图不包含像 DISTINCT 或 GROUP BY 这样的多行操作,它应该是可更新的。相关用户必须已被授予 UPDATE VIEW 权限。
A simple view with columns removed should definitely be updatable proividing you have privs to update the view in question...
删除列的简单视图绝对应该是可更新的,前提是您拥有更新相关视图的权限...
GRANT UPDATE ON your_view_name TO your_user;
What error(s) are you getting when you try to run the UPDATE statement?
尝试运行 UPDATE 语句时遇到什么错误?
回答by Ian Carpenter
In oracle a view contains no base data of it's own. So if your view allows updates then the underlying table will be updated.
在 oracle 中,视图不包含它自己的基础数据。因此,如果您的视图允许更新,则基础表将被更新。
If you need more information it is worth looking at the "views" section in the Oracle concepts guide.
如果您需要更多信息,则值得查看 Oracle 概念指南中的“视图”部分。
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#sthref787
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#sthref787
Further information can also be found in the "Create View" sql command.
还可以在“创建视图”sql 命令中找到更多信息。
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_8004.htm#SQLRF01504
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_8004.htm#SQLRF01504
Hope this helps
希望这可以帮助
Regards
问候