Managing System Privileges
To perform actions on schema objects, you must be granted the appropriate system privileges.
-
About System Privileges
A system privilege is the right to perform an action or to perform actions on schema objects. -
Who Can Grant or Revoke System Privileges?
Only two types of users can grant system privileges to other users or revoke those privileges from them. -
Why Is It Important to Restrict System Privileges?
System privileges are very powerful, so only grant them to trusted users. You should also secure the data dictionary andSYSschema objects. -
Grants and Revokes of System Privileges
You can grant or revoke system privileges to users and roles. -
About ANY Privileges and the PUBLIC Role
System privileges that use theANYkeyword enable you to set privileges for an entire category of objects in the database.
About System Privileges
A system privilege is the right to perform an action or to perform actions on schema objects.
For example, the privileges to create tablespaces and to delete the rows of any table in a database are system privileges.
There are many different kinds of system privileges. Each system privilege allows a user to perform a particular database operation or class of database operations. Remember that system privileges are very powerful. Only grant them when necessary to roles and trusted users of the database. To find the system privileges that have been granted to a user, you can query the DBA_SYS_PRIVS data dictionary view.
If you want to restrict a system privilege to a specific schema, then you can do so by granting it as a schema privilege. A schema privilege enables you to grant a specific system privilege on a schema without having to perform a grant on every object within the schema.
System privileges such as SELECT ANY TABLE do not work on SYS objects or other objects that are owned by schemas that are marked as DICTIONARY PROTECTED.
Related Topics
Who Can Grant or Revoke System Privileges?
Only two types of users can grant system privileges to other users or revoke those privileges from them.
These users are as follows:
-
Users who were granted a specific system privilege with the
ADMINOPTION -
Users with the system privilege
GRANTANYPRIVILEGE
For this reason, only grant these privileges to trusted users.
Why Is It Important to Restrict System Privileges?
System privileges are very powerful, so only grant them to trusted users. You should also secure the data dictionary and SYS schema objects.
-
About the Importance of Restricting System Privileges
System privileges are very powerful, so by default the database is configured to prevent typical (non-administrative) users from exercising theANYsystem privileges. -
User Access to Objects in the SYS Schema
Users with explicit object privileges or those who connect with administrative privileges (SYSDBA) can access objects in theSYSschema.
About the Importance of Restricting System Privileges
System privileges are very powerful, so by default the database is configured to prevent typical (non-administrative) users from exercising the ANY system privileges.
For example, users are prevented from exercising ANY system privileges such as UPDATE ANY TABLE on the data dictionary.
Related Topics
User Access to Objects in the SYS Schema
Users with explicit object privileges or those who connect with administrative privileges (SYSDBA) can access objects in the SYS schema.
The following table lists roles that you can grant to users who need access to objects in the SYS schema.
| Role | Description |
|---|---|
SELECT_CATALOG_ROLE |
Grant this role to allow users SELECT privileges on data dictionary views. |
EXECUTE_CATALOG_ROLE |
Grant this role to allow users EXECUTE privileges for packages and procedures in the data dictionary. |
Additionally, you can grant the SELECT ANY DICTIONARY system privilege to users who require access to tables created in the SYS schema. This system privilege allows query access to any object in the SYS schema, including tables created in that schema. It must be granted individually to each user requiring the privilege. It is not included in GRANT ALL PRIVILEGES, but it can be granted through a role.
In earlier releases, the DBA_TAB_STAT_PREFS view could be queried by any user with the PUBLIC role. Starting with Oracle Database 19c, Release Update 19.28, this view adheres to the convention for DBA_ views, that is, it can be queried only by users with the SYSDBA system privilege or SELECT ANY DICTIONARY privilege, or SELECT_CATALOG_ROLE role, or by users with direct privileges granted to them. This change improves access control for optimizer and statistics metadata and reduces information disclosure.
Note: You should grant these roles and the SELECT ANY DICTIONARY system privilege with extreme care, because the integrity of your system can be compromised by their misuse.
Grants and Revokes of System Privileges
You can grant or revoke system privileges to users and roles.
If you grant system privileges to roles, then you can use the roles to exercise system privileges. For example, roles permit privileges to be made selectively available. Ensure that you follow separation of duty guidelines for securing roles.
Use either of the following methods to grant or revoke system privileges to or from users and roles:
-
GRANTandREVOKESQL statements -
Oracle Enterprise Manager Cloud Control
Related Topics
About ANY Privileges and the PUBLIC Role
System privileges that use the ANY keyword enable you to set privileges for an entire category of objects in the database.
For example, the CREATE ANY PROCEDURE system privilege permits a user to create a procedure anywhere in the database. The behavior of an object created by users with the ANY privilege is not restricted to the schema in which it was created. For example, if user JSMITH has the CREATE ANY PROCEDURE privilege and creates a procedure in the schema JONES, then the procedure will run as JONES. However, JONES may not be aware that the procedure JSMITH created is running as JONES. If JONES has DBA privileges, letting JSMITH run a procedure as JONES could pose a security violation.
The PUBLIC role is a special role that every database user account automatically has when the account is created. By default, it has no privileges granted to it, but it does have numerous grants, mostly to Java objects. You cannot drop the PUBLIC role, and a manual grant or revoke of this role has no meaning, because the user account will always assume this role. Because all database user accounts assume the PUBLIC role, it does not appear in the DBA_ROLES and SESSION_ROLES data dictionary views.
You can grant privileges to the PUBLIC role, but remember that this makes the privileges available to every user in the Oracle database. For this reason, be careful about granting privileges to the PUBLIC role, particularly powerful privileges such as the ANY privileges and system privileges. For example, if JSMITH has the CREATE PUBLIC SYNONYM system privilege, JSMITH could redefine an interface that they know everyone else uses, and then point to it with the PUBLIC SYNONYM that JSMITH created. Instead of accessing the correct interface, users would access the interface of JSMITH, which could possibly perform illegal activities such as stealing the login credentials of users.
These types of privileges are very powerful and could pose a security risk if given to the wrong person. Be careful about granting privileges using ANY or PUBLIC. As with all privileges, you should follow the principles of “least privilege” when granting these privileges to users.
Related Topics
Managing Schema Privileges
Schema privileges enable certain system privileges to be granted on a schema.
-
About Managing Schema Privileges
When a schema privilege is granted on a schema, the grantee has the system privilege on all the objects in the schema on which the grant has been made. -
Privileges That Are Excluded from Schema Privilege Grants
Many administrative and system privileges cannot be used in schema privilege grants. -
Granting a Schema Privilege
You can use theGRANTstatement to grant a schema privilege to a user or a role. -
Revoking a Schema Privilege
You can use theREVOKEstatement to revoke a schema privilege from a user or a role.
About Managing Schema Privileges
When a schema privilege is granted on a schema, the grantee has the system privilege on all the objects in the schema on which the grant has been made.
The system privilege applies to both current and future objects in the schema. For example, suppose you grant the CREATE ANY TABLE system privilege to user psmith for use on the HR schema. User psmith is then able to create tables in the HR schema and not in any other schema for which psmith does not have permission. You can grant the schema privilege to either users or roles. Schema privilege grants can be used on a wide range of system privileges, though not all. In addition, you cannot use schema privileges on the SYS schema. Because this grant provides powerful privileges to the grantee, ensure that you grant the schema privilege to trusted users only.
Granting users schema privileges has the following benefits:
-
Granting schema privileges instead of system privileges allows use of the principle of least privilege. Granting a system privilege could be unnecessarily permissive, because it allows the same privilege on any object in any schema in the database, whereas by granting only a schema privilege to a user or role, the user or role would be granted the least privilege necessary to accomplish their task. Hence, this approach makes the database more secure.
-
This type of privilege grant makes the granting of privileges much easier. Rather than having to grant the system or object privilege individually to a user, an administrator can grant the privilege to the schema so that all objects within the schema are accessible to the user.
To grant or revoke schema privileges, you must have the GRANT ANY SCHEMA PRIVILEGE or the GRANT ANY PRIVILEGE system privilege.
The ANY system privileges that you can include in the schema grants cover operations such as creation, altering, executing, dropping of objects.
The Oracle AI Database SQL Language Reference provides a list of the available system privileges that you can grant as schema privileges.
To find information about schema privilege grants, query the following data dictionary views:
-
DBA_SCHEMA_PRIVS -
ROLE_SCHEMA_PRIVS -
USER_SCHEMA_PRIVS -
SESSION_SCHEMA_PRIVS -
V$ENABLEDSCHEMAPRIVS
Related Topics
Privileges That Are Excluded from Schema Privilege Grants
Many administrative and system privileges cannot be used in schema privilege grants.
The following administrative privileges are excluded from schema privilege grants:
-
SYSDBA -
SYSOPER -
SYSASM -
SYSBACKUP -
SYSDG -
SYSKM
The following table lists system privileges that are excluded from schema privilege grants.
| System Privilege Type | Privilege |
|---|---|
| Advisor framework | ADVISORADMINISTER SQL TUNING SET |
| Application context | CREATE ANY CONTEXTDROP ANY CONTEXT |
| Application continuity | KEEP DATE TIMEKEEP SYSGUID |
| Database change notification | CHANGE NOTIFICATION |
| Database links | CREATE DATABASE LINKCREATE PUBLIC DATABASE LINKDROP PUBLIC DATABASE LINK |
| Database triggers | ADMINISTER DATABASE TRIGGER |
| Debugging | DEBUG CONNECT SESSION |
| Dictionary protection | SELECT ANY DICTIONARYANALYZE ANY DICTIONARY |
| Directories | CREATE ANY DIRECTORYDROP ANY DIRECTORYREADWRITE |
| Editions | CREATE ANY EDITIONDROP ANY EDITION |
| Exports and imports | EXPORT FULL DATABASEIMPORT FULL DATABASE |
| Flashback | FLASHBACK ARCHIVE ADMINISTERSELECT ANY TRANSACTION |
| Key management | ADMINISTER KEY MANAGEMENT |
| Logminer | LOGMINING |
| Plan management | ADMINISTER SQL MANAGEMENT OBJECT |
| Pluggable databases | CREATE PLUGGABLE DATABASESET CONTAINER |
| Profiles | CREATE PROFILEALTER PROFILEDROP PROFILE |
| Public synonyms | CREATE PUBLIC SYNONYMDROP PUBLIC SYNONYM |
| Recycle bin | PURGE DBA_RECYCLEBIN |
| Resource management | ADMINISTRATE RESOURCE MANAGER |
| Resumable space allocation | RESUMABLE |
| Roles | CREATE ROLEDROP ANY ROLEGRANT ANY ROLEALTER ANY ROLE |
| Rollback segment | CREATE ROLLBACK SEGMENTALTER ROLLBACK SEGMENTDROP ROLLBACK SEGMENT |
| Sessions | CREATE SESSIONALTER SESSIONRESTRICT SESSION |
| Stored outlines | CREATE ANY OUTLINEALTER ANY OUTLINEDROP ANY OUTLINE |
| System | ALTER DATABASEALTER SYSTEMAUDIT SYSTEMALTER RESOURCE COST |
| Tablespaces | CREATE TABLESPACEALTER TABLESPACEMANAGE TABLESPACEDROP TABLESPACEUNLIMITED TABLESPACE |
| Transactions | FORCE TRANSACTIONFORCE ANY TRANSACTION |
| Users | CREATE USERBECOME USERALTER USERDROP USER |
Granting a Schema Privilege
You can use the GRANT statement to grant a schema privilege to a user or a role.
-
Log in to the CDB root or to a PDB as a user who has been granted the
GRANT ANY SCHEMA PRIVILEGEorGRANT ANY PRIVILEGEsystem privilege. -
To find the available schema privileges that you can grant, see Oracle AI Database SQL Language Reference
-
Grant the schema privilege to the user or role.
For example, suppose you grant the
SELECT ANY TABLEsystem privilege to userpsmithfor use on theHRschema. Userpsmithis then able to select from existing and future tables that are created in theHRschema.GRANT SELECT ANY TABLE ON SCHEMA HR TO psmith;If you have the
GRANT ANY SCHEMA PRIVILEGE WITH ADMIN OPTIONprivilege, then you can do two additional types of grants:-
Grant
GRANT ANY SCHEMA PRIVILEGEto another user. -
Grant a schema privilege
WITH ADMIN OPTION, so that the user can grant the schema privilege to another user.
-
Revoking a Schema Privilege
You can use the REVOKE statement to revoke a schema privilege from a user or a role.
-
Log in to the CDB root or to a PDB as a user who has been granted the
GRANT ANY SCHEMA PRIVILEGEsystem privilege withWITH ADMIN OPTION. -
To find the schema privileges that have been granted to the user or role, run a query similar to the following:
For example:
SELECT PRIVILEGE, SCHEMA FROM DBA_SCHEMA_PRIVS WHERE GRANTEE = 'PSMITH';Output similar to the following appears:
PRIVILEGE SCHEMA --------------------- ------------ SELECT ANY TABLE HR -
Revoke the schema privileges from the user or role.
For example, to revoke the
SELECT ANY TABLEschema privilege from userpsmith:REVOKE SELECT ANY TABLE ON SCHEMA HR FROM psmith;
Administering Schema Security Policies
To manage schema security policies for row level security, fine-grained auditing, and Oracle Data Redaction, users must be granted the appropriate system privilege.
-
About Administering Schema System Security Policies
Security policies for row level security, fine-grained auditing, and Oracle Data Redaction require special schema-related system privileges. -
Granting an Administrator Schema Security Policy
You can use theGRANTstatement to grant a schema system privilege to a user or role. -
Revoking an Administrator Security Policy
You can use theREVOKEstatement to revoke a schema system privilege from a user or role.
About Administering Schema System Security Policies
Security policies for row level security, fine-grained auditing, and Oracle Data Redaction require special schema-related system privileges.
The system privileges and their corresponding PL/SQL packages that the user must be granted are as follows:
-
ADMINISTER ROW LEVEL SECURITY POLICYsystem privilege, for use with theDBMS_RLSPL/SQL package -
ADMINISTER FINE GRAINED AUDIT POLICYsystem privilege, for use with theDBMS_FGAPL/SQL package -
ADMINISTER REDACTION POLICYsystem privilege, for use with theDBMS_REDACTPL/SQL package
You must grant the system privilege to the user in addition to the other required privileges that are needed for the security policy, such as the EXECUTE privilege on any PL/SQL packages. You can grant the system privilege in either of the following ways:
-
If the security policy is to apply to all non-
SYSschemas across the database, then use the following syntax:GRANT system_privilege TO grantee; -
If the security policy is to be restricted to a specific schema, then use this syntax:
GRANT system_privilege ON SCHEMA schema TO grantee;
Granting an Administrator Schema Security Policy
You can use the GRANT statement to grant a schema system privilege to a user or role.
-
Log in to the CDB root or to a PDB as a user who has been granted the
GRANT ANY SCHEMA PRIVILEGEsystem privilege withWITH ADMIN OPTION. -
Grant the user the
EXECUTEprivilege on the PL/SQL package (and any other necessary privileges) to administer the security policy.For example, for a user who is responsible for creating row level security policies:
GRANT EXECUTE ON DBMS_RLS TO preston; -
Grant the user the schema system privilege.
For example, to restrict row level security policies to the
HRschema:GRANT ADMINISTER ROW LEVEL SECURITY POLICY ON SCHEMA HR TO preston;To enable the user to create the policy in any non-
SYSschema in the database:GRANT ADMINISTER ROW LEVEL SECURITY POLICY TO preston;
Revoking an Administrator Security Policy
You can use the REVOKE statement to revoke a schema system privilege from a user or role.
-
Log in to the CDB root or to a PDB as a user who has been granted the
GRANT ANY SCHEMA PRIVILEGEsystem privilege withWITH ADMIN OPTION. -
To find the system privileges that have been granted to the user or role, run a query similar to the following:
For example:
SELECT PRIVILEGE FROM DBA_SYS_PRIVS_ALL WHERE GRANTEE = 'PRESTON';Output similar to the following appears:
PRIVILEGE ------------------------------------- ADMINISTER ROW LEVEL SECURITY POLICY -
Revoke the system privilege from the user or role.
For example:
REVOKE ADMINISTER ROW LEVEL SECURITY POLICY ON SCHEMA HR FROM preston;Or:
REVOKE ADMINISTER ROW LEVEL SECURITY POLICY FROM preston; -
Revoke any other privileges as necessary, such as the
EXECUTEprivilege on the associated PL/SQL package.For example:
REVOKE EXECUTE ON DBMS_RLS FROM preston;
Managing Privileges to Enable Diagnostics
Only users who have the SYSDBA administrative privilege or the ENABLE_DIAGNOSTICS system privilege can enable diagnostics.
The kinds of diagnostics that you can restrict control of include the following: debug-events (events++, error-numbers) and debug-actions through ALTER SESSION and ALTER SYSTEM operations.
To control the ability of users to perform these types of diagnostics, set the DIAGNOSTICS_CONTROL initialization parameter in the initialization file.
DIAGNOSTICS_CONTROL values are as follows:
-
ERROR: If a user who does not have theSYSDBAorENABLE DIAGNOSTICSprivilege attempts to enable a diagnostic, then the attempt will fail and anORA-01031: insufficient privilegeserror appears. -
WARNING: A user who does not have theSYSDBAorENABLE DIAGNOSTICSprivilege will be able to enable a diagnostic, but a warning message is written to an alert log. The warning message is similar to the following:User 'USERNAME' has set the following debug-event(s) on the event-group 'session': 1357 trace name context forever, level 2In this message, the
sessionkeyword is used if the user run anALTER SESSIONstatement. If the user runs anALTER SYSTEMstatement, then the keyword issystem. -
IGNORE: The user can perform the diagnostic task without any error messages appearing. This setting is the default.