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_security
can be access globally and can be set from pkg_security
package.
An application context is a set of name-value pairs that Oracle Database stores in memory. The application context has a label called a namespace (for example, empno_ctx for an application context that retrieves employee IDs).
SYS_CONTEXT returns the value of parameter associated with the context namespace . You can use this function in both SQL and PL/SQL statements. For namespace and parameter , you can specify either a string or an expression that resolves to a string designating a namespace or an attribute.
A namespace is the categorisation which objects are identified (and hence typically will need unique naming). eg. <code> SQL> select object_type, namespace. 2 from dba_objects.
USERENV is a legacy function that is retained for backward compatibility. Oracle recommends that you use the SYS_CONTEXT function with the built-in USERENV namespace for current functionality. See SYS_CONTEXT for more information. USERENV returns information about the current session.
You can query the DBA_CONTEXT
(or [ALL_CONTEXT][1]
) view depending on your privileges and what contexts you're looking at. ALL_CONTEXT
will list all the contexts that have attributes set in the current session. DBA_CONTEXT
lists all the contexts in the database. However, you need to have additional privileges to be able to query the DBA_CONTEXT
view (the SELECT ANY DICTIONARY
privilege or SELECT_CATALOG_ROLE
role would be more than sufficient but you can also be granted access to that view specifically)
SELECT namespace,
schema,
package,
type
FROM dba_context
will have a row for the HR_SECURITY
namespace showing that it is associated with the PKG_SECURITY
package with a TYPE
of ACCESSED GLOBALLY
.
Alternatively you can use ALL_OBJECTS if you lack grants for DBA_CONTEXT. But to list all global contexts which were created by respective user would require additional naming convention to distinguish who created this global context (as in your example owner of object will be SYS and not HR)
SELECT * FROM ALL_OBJECTS AO WHERE AO.OBJECT_TYPE = 'CONTEXT' AND AO.OBJECT_NAME LIKE 'HR%' AND AO.OWNER = 'SYS';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With