简体   繁体   English

如何在Oracle中允许更新视图的结果?

[英]How to permit update of a view's results in Oracle?

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? 改写:如果我仅查看一个表,只是为了隐藏一些列,对此数据的更改会在表上更新吗?

Yes, Oracle views can be modified. 是的,可以修改Oracle视图。

There are, however, some restrictions: 但是,有一些限制:

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. 我不相信默认情况下Oracle视图是只读的...单个表视图应该是可更新的,前提是它不包含DISTINCT或GROUP BY这样的多行操作。 The user in question must have been granted UPDATE VIEW privs. 有问题的用户必须已被授予UPDATE VIEW privs。

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语句时遇到什么错误?

In oracle a view contains no base data of it's own. 在oracle中,视图不包含其自身的基本数据。 So if your view allows updates then the underlying table will be updated. 因此,如果您的视图允许更新,则基础表将被更新。

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 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM