---
title: "Oracle Roles (转载)"
author: "zhyiwww"
date: "2008-11-06T18:16:00Z"
tags: ["Access", "Oracle", "SQL", "SQL Server", "Web"]
slug: "oracle-roles"
draft: false
lastmod: "2008-11-06T18:16:00Z"
id: 580836
url: "https://zhyiwww.iteye.com/blog/580836"
---

[**Oracle Roles**](http://www.psoug.org/reference/roles.html) **Version 10.2**

**General** Data Dictionary Objects Related to Roles

defrole$ user$ dba\_roles session\_roles dba\_role\_privs user\_application\_roles role\_role\_privs user\_role\_privs role\_sys\_privs v$pwfile\_users role\_tab\_privs

System Privileges Related To Roles

alter any role create role drop any role grant any role

Installation roles

**Role Name** **Description** AQ\_ADMINISTRATOR\_ROLE Privilege to administer Advanced Queuing AQ\_USER\_ROLE Deprecated AUTHENTICATEDUSER DBUriServlet Security CONNECT Contains the create session privilege (only) CSW\_USR\_ROLE Not documented CTXAPP Enables developers create Oracle Text indexes and index preferences, and to use PL/SQL packages. CWM\_USER Undocumented DATAPUMP\_EXP\_FULL\_DATABASE Undocumented DATAPUMP\_IMP\_FULL\_DATABASE Undocumented DBA Example Database Administrator role. Should not be used DELETE\_CATALOG\_ROLE Allow users to delete records from the system audit table (AUD$) DMUSER\_ROLE Undocumented DM\_CATALOG\_ROLE Undocumented EJBCLIENT Undocumented EXECUTE\_CATALOG\_ROLE Allow users EXECUTE privileges for packages and procedures in the data dictionary  
EXP\_FULL\_DATABASE Provides the privileges required to perform full and incremental database exports, and includes: SELECT ANY TABLE, BACKUP ANY TABLE, EXECUTE ANY PROCEDURE, EXECUTE ANY TYPE, ADMINISTER RESOURCE MANAGER, and INSERT, DELETE, and UPDATE on the tables SYS.INCVID, SYS.INCFIL, and SYS.INCEXP. Also the following roles: EXECUTE\_CATALOG\_ROLE and SELECT\_CATALOG\_ROLE. GATHER\_SYSTEM\_STATISTICS To update the dictionary system statistics a user must have DBA privileges or the GATHER\_SYSTEM\_STATISTICS role. GLOBAL\_AQ\_USER\_ROLE Required to register through LDAP using JDBC connection parameters as this requires the ability to write access to the connection factory entries in the LDAP server (which requires the LDAP user to be either the database itself or be granted GLOBAL\_AQ\_USER\_ROLE).  
HS\_ADMIN\_ROLE Provides privileges for DBAs who need to use the DBA role using Oracle Database Heterogeneous Services to access appropriate tables in the data dictionary.

Used to protect access to the Heterogeneous Services (HS) data dictionary tables (grants SELECT) and packages (grants EXECUTE). It is granted to SELECT\_CATALOG\_ROLE and EXECUTE\_CATALOG\_ROLE such that users with generic data dictionary access also can access the HS data dictionary.  
IMP\_FULL\_DATABASE Provides the privileges required to perform full database imports. Includes an extensive list of system privileges (use view DBA\_SYS\_PRIVS to view privileges) and the following roles: EXECUTE\_CATALOG\_ROLE and SELECT\_CATALOG\_ROLE.

This role is provided for convenience in using the export and import utilities. JAVADEBUGPRIV Grants permissions to run the Java debugger JAVAIDPRIV Undocumented JAVASYSPRIV Grants permissions for Java administrators including updating JVM-protected packages JAVAUSERPRIV Grants permissions for Java users such as examining properties JAVA\_ADMIN Java administration privileges including permission to modify PolicyTable. JAVA\_DEPLOY Undocumented JMXSERVER Provides permissions to start and maintain a JMX agent in a session. The procedure dbms\_java.start\_jmx\_agent starts the agent in a specific session that generally remains active for the duration of the session. LOGSTDBY\_ADMINISTRATOR A prototype role created by default with RESOURCE, and EXECUTE on DBMS\_LOGSTDBY privileges.

It is advisable to not use this role but rather to craft your own specific to your needs. Read Oracle's comments, in red with respect to RESOURCE. They apply here too. MGMT\_USER Undocumented OEM\_ADVISOR Required to run the Segment Advisor manually with Enterprise Manager. OEM\_MONITOR Undocumented OLAPI\_TRACE\_USER Undocumented OLAP\_DBA To create dimensional objects in any schema OLAP\_USER Create dimensional objects OLAP\_XS\_ADMIN Administer OLAP data security ORDADMIN After installing Oracle Multimedia DICOM, the ORDADMIN role is created, with the database system privileges required for administration of the DICOM data model repository.

The ORDADMIN role must be assigned to the administrator of the DICOM data model repository. OWB$CLIENT Privileges granted to PUBLIC are available to all sessions. OWB\_DESIGNCENTER\_VIEW Undocumented OWB\_USER With Oracle Warehouse builder enables a remote Oracle WorkFlow instance to connect to the services provided by the Control Center. PLUSTRACE Traditionally required to use AUTOTRACE but in 11gR1 it seems to function without this role being required. PUBLIC -  
RECOVERY\_CATALOG\_OWNER Provides privileges for owner of the recovery catalog. Includes: CREATE SESSION, ALTER SESSION, CREATE SYNONYM, CREATE VIEW, CREATE DATABASE LINK, CREATE TABLE, CREATE CLUSTER, CREATE SEQUENCE, CREATE TRIGGER, and CREATE PROCEDURE  
RESOURCE Provides the following system privileges: CREATE CLUSTER, CREATE INDEXTYPE, CREATE OPERATOR, CREATE PROCEDURE, CREATE SEQUENCE, CREATE TABLE, CREATE TRIGGER, CREATE TYPE.

This role is provided for compatibility with previous releases of Oracle Database. You can determine the privileges encompassed by this role by querying the DBA\_SYS\_PRIVS data dictionary view.

Note: Oracle recommends that you design your own roles for database security rather than relying on this role. This role may not be created automatically by future releases of Oracle Database. SCHEDULER\_ADMIN Allows the grantee to execute the procedures of the DBMS\_SCHEDULER package. It includes all of the job scheduler system privileges and is included in the DBA role. SELECT\_CATALOG\_ROLE Provides SELECT privilege on objects in the data dictionary. Also provides the HS\_ADMIN\_ROLE privilege. SPATIAL\_CSW\_ADMIN Privileges granted the Catalog Services for the Web (CSW) account used by the Oracle Spatial CSW cache manager to load all record type metadata, and record instances from the database into the main memory for the record types that are cached. SPATIAL\_WFS\_ADMIN Privileges granted the Web Feature Service (WFS) account used by the Oracle Spatial WFS cache manager to load all feature type metadata, and feature instances from the database into main memory for the feature types that are cached. WFS\_USR\_ROLE Privileges granted a Web Feature Service (WFS) user WKUSER Privileges that must be granted to database users hosting new Oracle Ultra Search instances. WM\_ADMIN\_ROLE Contains all Workspace Manager privileges with the grant option. By default, the database administrator (DBA role) is granted the WM\_ADMIN\_ROLE role. XDBADMIN Allows the grantee to register an XML schema globally, as opposed to registering it for use or access only by its owner. It also lets the grantee bypass access control list (ACL) checks when accessing Oracle XML DB Repository. XDB\_SET\_INVOKER Allows the grantee to define invoker's rights handlers and to create or update the resource configuration for XML repository triggers. By default, Oracle Database grants this role to the DBA role but not to the XDBADMIN role. XDB\_WEBSERVICES Allows the grantee to access Oracle Database Web services over HTTPS. However, it does not provide the user access to objects in the database that are public. To allow public access, you need to grant the user the XDB\_WEBSERVICES\_WITH\_PUBLIC role. For a user to use these Web services, SYS must enable the Web service servlets. XDB\_WEBSERVICES\_OVER\_HTTP Allows the grantee to access Oracle Database Web services over HTTP. However, it does not provide the user access to objects in the database that are public. To allow public access, you need to grant the user the XDB\_WEBSERVICES\_WITH\_PUBLIC role. XDB\_WEBSERVICES\_WITH\_PUBLIC Allows the grantee access to public objects through Oracle Database Web services.

Roles are treated like users in the data dictionary SELECT name USER\_NAMES  
FROM user$  
WHERE type# = 1;

SELECT name ROLE\_NAMES  
FROM user$  
WHERE type# = 0; Controlling The Number Of Roles With An init.ora Parameter max\_enabled\_roles = &lt;integer&gt; max\_enabled\_roles = 100 NOTE:

- Roles can contain system privileges
- Roles can contain object privileges
- Roles can contain roles
- Object privileges granted through roles do not work within procedures, functions, and packages. Those permissions must be granted explicitly to the user.

**Creating Roles** Create Role CREATE ROLE &lt;role\_name&gt;; CREATE ROLE read\_only; Create Password Protected Role CREATE ROLE &lt;role\_name&gt; IDENTIFIED BY &lt;password&gt;; CREATE ROLE dba IDENTIFIED BY "S0^Sorry"; **Assigning Privileges And Roles To Roles** Assign Privilege To A Role GRANT &lt;privilege\_name&gt; TO &lt;role\_name&gt;; GRANT create session TO read\_only Create A Role Heirarchy GRANT &lt;role\_name&gt; TO &lt;role\_name&gt;; CREATE ROLE ap\_clerk;

GRANT read\_only TO ap\_clerk;  
GRANT select ON general\_ledger TO ap\_clerk;  
GRANT insert ON ap\_master TO ap\_clerk;  
GRANT update ON ap\_master TO ap\_clerk;  
GRANT insert ON ap\_detail TO ap\_clerk;  
GRANT update ON ap\_detail TO ap\_clerk; Add Another Layer To The Heirarchy GRANT &lt;roles and privileges&gt; TO &lt;role\_name&gt;; CREATE ROLE ap\_manager IDENTIFIED BY appwd;

GRANT ap\_clerk TO ap\_manager;  
GRANT delete ON ap\_master TO ap\_manager;  
GRANT delete ON ap\_detail TO ap\_manager;  
GRANT select any table TO ap\_manager; **Assigning Roles** Assigning Roles To Users GRANT &lt;roles\_name&gt; TO &lt;user\_name&gt;; GRANT read\_only TO jcline;

GRANT ap\_clerk TO jstough;  
GRANT ap\_clerk TO ckeizer;  
GRANT ap\_clerk TO rallen;

GRANT ap\_manager TO escott; **Revoking Privileges From Roles** Revoke Privilege REVOKE &lt;privilege\_name&gt; FROM &lt;role\_name&gt;; REVOKE select any table FROM ap\_manager; **Revoking Roles** Revoke a role from a user REVOKE &lt;role\_name&gt; FROM &lt;user\_name&gt;; REVOKE ap\_manager FROM escott; Revoke A Role And Drop Any Invalidated Constraints REVOKE ALL ON &lt;table\_name&gt;  
FROM &lt;schema\_name&gt;  
CASCADE CONSTRAINTS; REVOKE ALL ON invoices  
FROM abc  
CASCADE CONSTRAINTS; **Activating & Decactivating Roles** Activating A Role SET ROLE &lt;role\_name&gt;; SET ROLE ap\_clerk; Activating A Password Protected Role SET ROLE &lt;role\_name&gt; IDENTIFIED BY &lt;role\_password&gt;; SET ROLE ap\_manager IDENTIFIED BY appwd; Activating All Roles SET ROLE all; Activating All Roles Except One SET ROLE all EXCEPT &lt;role\_name&gt;; SET ROLE all EXCEPT ap\_manager; Deactivating A Role Can not be done on an individual basis Deactivating All Roles SET ROLE none; **Drop Role** Dropping A Role DROP ROLE &lt;role\_name&gt;; DROP ROLE manager\_role; **PLUSTRACE Role** Creating And Assigning The PLUSTRACE Role Used By AUTOTRACE This role must be created by SYS and grants SELECT on the following v\_$ views:

- V\_$SESSTAT
- V\_$STATNAME
- V\_$MYSTAT

SQL&gt; @c:\\oracle\\product\\ora10\\sqlplus\\admin\\plustrce.sql

GRANT plustrace TO uwclass; **Role Related Queries** All Roles Available In The Database SELECT name  
FROM user$  
WHERE type# = 0; Roles Granted To A User SELECT *  
FROM user\_role\_privs; Privileges Granted To A Role SELECT *  
FROM role\_sys\_privs; System Privileges SELECT DISTINCT privilege  
FROM dba\_sys\_privs; Grant SELECT On All Tables In A Schema CREATE OR REPLACE PROCEDURE GRANT\_SELECT AS

CURSOR ut\_cur IS  
SELECT table\_name  
FROM user\_tables;

RetVal NUMBER;  
sCursor INT;  
sqlstr VARCHAR2(250);

BEGIN  
FOR ut\_rec IN user\_tabs\_cur;  
LOOP  
sqlstr := 'GRANT SELECT ON '||ut\_rec.table\_name  
|| ' TO jwc7675';  
sCursor := dbms\_sql.open\_cursor;  
dbms\_sql.parse(sCursor,sqlstr, dbms\_sql.native);

RetVal := dbms\_sql.execute(sCursor);  
dbms\_sql.close\_cursor(sCursor);  
END LOOP;  
END grant\_select; Roles Granted To Schemas SELECT grantee, granted\_role  
FROM dba\_role\_privs; Tables And Columns That Can Be Modified by a User SELECT *  
FROM all\_updatable\_columns;

**Other Related Topics** [Autotrace](http://www.psoug.org/reference/autotrace.html) [Consumer Groups](http://www.psoug.org/reference/dbms_res_mgr.html) [Object Privileges](http://www.psoug.org/reference/object_privs.html) [Profiles](http://www.psoug.org/reference/profiles.html) [System Privileges](http://www.psoug.org/reference/system_privs.html) [Users](http://www.psoug.org/reference/user.html)

[Contact Us](http://www.psoug.org/reference/about.html) � [Legal Notices and Terms of Use](http://www.psoug.org/reference/legal.html) � [Privacy Statement](http://www.psoug.org/reference/privacy.html)