

# RDS for Oracle users and privileges

When you create an Amazon RDS for Oracle DB instance, the default master user has most of the maximum user permissions on the DB instance. Use the master user account for any administrative tasks, such as creating additional user accounts in your database. Because RDS is a managed service, you aren't allowed to log in as `SYS` and `SYSTEM`, and thus don't have `SYSDBA` privileges.

**Topics**
+ [Limitations for Oracle DBA privileges](#Oracle.Concepts.dba-limitations)
+ [How to manage privileges on SYS objects](#Oracle.Concepts.Privileges.SYS-objects)
+ [AWS managed database accounts and roles in RDS for Oracle](#Oracle.Concepts.Privileges.managed-accounts)

## Limitations for Oracle DBA privileges
<a name="Oracle.Concepts.dba-limitations"></a>

In the database, a role is a collection of privileges that you can grant to or revoke from a user. An Oracle database uses roles to provide security. For more information, see [Configuring Privilege and Role Authorization](https://docs.oracle.com/en/database/oracle/oracle-database/19/dbseg/configuring-privilege-and-role-authorization.html#GUID-89CE989D-C97F-4CFD-941F-18203090A1AC) in the Oracle Database documentation.

The predefined role `DBA` normally allows all administrative privileges on an Oracle database. When you create a DB instance, your master user account gets DBA privileges (with some limitations). To deliver a managed experience, an RDS for Oracle database doesn't provide the following privileges for the `DBA` role: 
+ `ALTER DATABASE`
+ `ALTER SYSTEM`
+ `CREATE ANY DIRECTORY`
+ `DROP ANY DIRECTORY`
+ `GRANT ANY PRIVILEGE`
+ `GRANT ANY ROLE`

For more RDS for Oracle system privilege and role information, see [Master user account privileges](UsingWithRDS.MasterAccounts.md).

## How to manage privileges on SYS objects
<a name="Oracle.Concepts.Privileges.SYS-objects"></a>

You can manage privileges on `SYS` objects by using the `rdsadmin.rdsadmin_util` package. For example, if you create the database user `myuser`, you could use the `rdsadmin.rdsadmin_util.grant_sys_object` procedure to grant `SELECT` privileges on `V_$SQLAREA` to `myuser`. For more information, see the following topics:
+ [Granting SELECT or EXECUTE privileges to SYS objects](Appendix.Oracle.CommonDBATasks.TransferPrivileges.md)
+ [Revoking SELECT or EXECUTE privileges on SYS objects](Appendix.Oracle.CommonDBATasks.RevokePrivileges.md)
+ [Granting privileges to non-master users](Appendix.Oracle.CommonDBATasks.PermissionsNonMasters.md)

## AWS managed database accounts and roles in RDS for Oracle
<a name="Oracle.Concepts.Privileges.managed-accounts"></a>

RDS for Oracle creates and uses several database accounts and roles to perform automated management tasks. These accounts and roles are reserved for RDS for Oracle. Don't use them for your applications or workloads.

Don't lock, drop, or rename these accounts, or change their passwords. Don't modify the privileges or grants of these accounts and roles. Changes like these might prevent RDS for Oracle from managing your DB instance, which can affect its availability.

The following are AWS managed accounts:
+ `RDSADMIN`
+ `RDS_DATAGUARD`
+ `RDSSEC`
+ `RDSPERFMON`
+ `RDSDBSNMP`
+ `OPS$RDSDB`
+ `RDSZEROETLADMIN`
+ `RDSADMIN$LIMITED`

Not all of these accounts are present in every DB instance. Their presence depends on the features and options enabled for the instance.

The following are AWS managed roles:
+ `OPS_RDSDB_READ_ONLY`
+ `OPS_RDSDB_READ_WRITE`

### Excluding AWS managed accounts from logon triggers
<a name="Oracle.Concepts.Privileges.managed-accounts.logon-triggers"></a>

If you create an `AFTER LOGON ON DATABASE` trigger, allow all AWS managed accounts to connect without restriction. Blocking these accounts can prevent Amazon RDS automation from running and may affect the availability of your DB instance.

Add a guard at the top of your trigger that returns immediately for all AWS managed accounts. The following example shows the recommended pattern using the `USER` function:

```sql
CREATE OR REPLACE TRIGGER my_logon_trigger
  AFTER LOGON ON DATABASE
DECLARE
  v_user VARCHAR2(100);
BEGIN
  v_user := USER;

  -- Allow AWS managed accounts to connect.
  IF v_user IN ('{{admin-user}}', 'SYS', 'SYSTEM',
                'RDSADMIN', 'OPS$RDSDB', 'RDSZEROETLADMIN', 'RDSADMIN$LIMITED',
                'RDS_DATAGUARD', 'RDSSEC', 'RDSPERFMON', 'RDSDBSNMP') THEN
    RETURN;
  END IF;

  -- Your custom trigger logic here.
EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    RAISE;
END;
/
```