如何列出 Oracle DB 中的所有上下文命名空间?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8295438/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:43:48  来源:igfitidea点击:

How do I list all context namespaces in Oracle DB?

oracleplsqloracle11g

提问by AppleGrew

If I create a context namespace:-

如果我创建一个上下文命名空间:-

CREATE OR REPLACE CONTEXT hr_security
    USING hr.pkg_security
    ACCESSED GLOBALLY;

How can I list all such namespaces and look up their properties. For example, hr_securitycan be access globally and can be set from pkg_securitypackage.

我怎样才能列出所有这样的命名空间并查找它们的属性。例如,hr_security可以全局访问,可以从pkg_security包中设置。

回答by Justin Cave

You can query the DBA_CONTEXT(or [ALL_CONTEXT][1]) view depending on your privileges and what contexts you're looking at. ALL_CONTEXTwill list all the contexts that have attributes set in the current session. DBA_CONTEXTlists all the contexts in the database. However, you need to have additional privileges to be able to query the DBA_CONTEXTview (the SELECT ANY DICTIONARYprivilege or SELECT_CATALOG_ROLErole would be more than sufficient but you can also be granted access to that view specifically)

您可以根据您的权限和您正在查看的上下文查询DBA_CONTEXT(或[ALL_CONTEXT][1]) 视图。 ALL_CONTEXT将列出在当前会话中设置了属性的所有上下文。 DBA_CONTEXT列出数据库中的所有上下文。但是,您需要具有额外的权限才能查询DBA_CONTEXT视图(SELECT ANY DICTIONARY权限或SELECT_CATALOG_ROLE角色已经绰绰有余,但您也可以被授予对该视图的特定访问权限)

SELECT namespace,
       schema,
       package,
       type
  FROM dba_context

will have a row for the HR_SECURITYnamespace showing that it is associated with the PKG_SECURITYpackage with a TYPEof ACCESSED GLOBALLY.

HR_SECURITY命名空间将有一行显示它PKG_SECURITY与具有TYPEof的包相关联ACCESSED GLOBALLY