Oracle:跨模式创建视图?

发布于 2024-10-15 07:12:44 字数 384 浏览 4 评论 0原文

我正在尝试创建一个视图,并将问题归结为无法创建引用不同架构中的表的视图。

例如,我可以这样做:

select count(*) from otherschema.othertable;

我可以这样做:

create view foo as select count(*) as bar from oneofmytables;

但如果我尝试:

create view foo as select count(*) as bar from otherschema.othertable;

我会收到“权限不足”错误。我还需要什么额外的特权?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

躲猫猫 2024-10-22 07:12:45

您是否直接授予其他用户的表?或者是通过角色?您需要直接授予权限才能创建引用其他表的对象(视图、过程等)。作为快速测试,在 SQL*Plus 中

SQL> set role none;
SQL> select count(*) from otherschema.othertable;

如果失败,则问题在于您已通过角色被授予了对该表的权限。

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> 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.

如若梦似彩虹 2024-10-22 07:12:45

我想您已经通过角色而不是直接授予otherschema.othertable上获得了选择权。

如果是这种情况,您应该以 otheruser 身份连接,然后对 othertable 执行 grant select to

I guess you have been given select right on otherschema.othertable via a role not via a direct grant.

If this is the case, you should connect as otheruser and then do a grant select on othertable to <your-schema>.

熟人话多 2024-10-22 07:12:45

我相信您的 DBA 需要授予您

创建任意视图

权限。根据您站点的安全限制,他们可能允许也可能不允许这样做。我通常不

I believe that your DBA will need to grant you

create any view

privilege. Depending on the security restrictions at your site they may or not allow this. I typically do not

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文