Oracle:创建跨模式的视图?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4855412/
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
Oracle: Creating view across schemas?
提问by chris
I'm trying to create a view, and have distilled the problem down to the inability to create a view that references tables from a different schema.
我正在尝试创建一个视图,并将问题归结为无法创建引用来自不同架构的表的视图。
For example, I can do:
例如,我可以这样做:
select count(*) from otherschema.othertable;
and I can do:
我可以这样做:
create view foo as select count(*) as bar from oneofmytables;
But if I try:
但如果我尝试:
create view foo as select count(*) as bar from otherschema.othertable;
I get an "insufficient privileges" error. What additional privileges do I need?
我收到“权限不足”错误。我需要什么额外的特权?
回答by Justin Cave
Do you have the grant to the other user's table directly? Or is it via a role? You will need the privilege to be granted directly in order to create an object (view, procedure, etc.) that references the other table. As a quick test, in SQL*Plus
您是否直接授予其他用户的表?还是通过角色?您需要直接授予特权才能创建引用其他表的对象(视图、过程等)。作为快速测试,在 SQL*Plus 中
SQL> set role none;
SQL> select count(*) from otherschema.othertable;
If that fails, then the problem is that you have been granted privileges on the table via a role.
如果失败,则问题在于您已通过角色获得了对该表的权限。
回答by René Nyffenegger
I guess you have been given select right on otherschema.othertable
via a role
not via a direct grant
.
我猜你已经otherschema.othertable
通过一个role
而不是通过一个直接的grant
.
If this is the case, you should connect as otheruser
and then do a grant select on othertable to <your-schema>
.
如果是这种情况,您应该连接 asotheruser
然后执行grant select on othertable to <your-schema>
.
回答by Michael Ballent
I believe that your DBA will need to grant you
我相信您的 DBA 需要授予您
create any view
创建任何视图
privilege. Depending on the security restrictions at your site they may or not allow this. I typically do not
特权。根据您站点的安全限制,他们可能允许或不允许这样做。我通常不