如何从另一个架构中选择特定于 Oracle 架构的视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4695796/
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 select a Oracle schema-specific view from another schema
提问by Martin08
Suppose I'm logged in as USERA, I want to access all the user_* views of the USERB schema, such as user_tables, user_tab_columns. How can I do this? Thanks
假设我以 USERA 身份登录,我想访问 USERB 架构的所有 user_* 视图,例如 user_tables、user_tab_columns。我怎样才能做到这一点?谢谢
回答by Justin Cave
All the USER_* tables have analogues with the ALL_* and DBA_* prefix. USER_TABLES has information about all the tables you own. ALL_TABLES has information about all the tables you have access to. DBA_TABLES has information about all the tables in your database.
所有 USER_* 表都有带有 ALL_* 和 DBA_* 前缀的类似物。USER_TABLES 包含有关您拥有的所有表的信息。ALL_TABLES 包含有关您有权访问的所有表的信息。DBA_TABLES 包含有关数据库中所有表的信息。
If you want to see information about UserB's tables
如果您想查看有关 UserB 表的信息
SELECT *
FROM all_tables
WHERE owner = 'USERB';
or
或者
SELECT *
FROM dba_tables
WHERE owner = 'USERB';
The former will work if you have SELECT access on User B's tables. The latter will work if your DBA has given you access to the DBA_TABLES view. That is normally done by granting the SELECT ANY DICTIONARY privilege (or the SELECT_CATALOG_ROLE in prior version) though the DBA can grant access to individual DBA_* views.
如果您对用户 B 的表具有 SELECT 访问权限,则前者将起作用。如果您的 DBA 已授予您对 DBA_TABLES 视图的访问权限,后者将起作用。这通常是通过授予 SELECT ANY DICTIONARY 权限(或先前版本中的 SELECT_CATALOG_ROLE)来完成的,尽管 DBA 可以授予对单个 DBA_* 视图的访问权限。
回答by OMG Ponies
USER_%
views give what you own, that is what's inside your schema.ALL_%
views give what you have access to.
USER_%
视图给出您拥有的内容,这就是您的架构中的内容。ALL_%
视图提供您可以访问的内容。
So what you really should use is ALL_TABLES/etc, and grant appropriate access to USERB
objects.
所以你真正应该使用的是 ALL_TABLES/etc,并授予对USERB
对象的适当访问权限。
回答by Colin Nicholls
Assuming you have permissions, you could try:
假设您有权限,您可以尝试:
ALTER SESSION SET CURRENT_SCHEMA=USERB;
更改会话集 CURRENT_SCHEMA=USERB;