RBAC in Oracle lets you bundle privileges into roles and assign those roles to users for simplified, secure access management.
Role-Based Access Control (RBAC) in Oracle groups privileges into roles that you grant to users or applications. Roles simplify security reviews, reduce direct grants, and let you enable or disable permissions in one step.
Roles scale better. Instead of granting SELECT on Customers
to every analyst, you grant the privilege once to a role such as customer_ro
and assign that role to all analysts.Revoking the role instantly removes access.
Use CREATE ROLE
.Optionally protect the role with a password so only DBAs can enable it within a session.
CREATE ROLE customer_ro IDENTIFIED BY customer_ro_pwd;
CREATE ROLE customer_ro IDENTIFIED BY customer_ro_pwd;
GRANT SELECT ON Customers TO customer_ro;
GRANT SELECT ON Orders TO customer_ro;
After creating the role, grant table or view privileges just as you would to a user.
GRANT SELECT, UPDATE ON Products TO sales_ops;
Grant the role to each user.You can make the role default so it is enabled automatically.
GRANT customer_ro TO analyst_jane; -- non-default
GRANT sales_ops TO seller_app WITH ADMIN OPTION;
ALTER USER analyst_jane DEFAULT ROLE customer_ro;
Protect a role with a password or make it NOT IDENTIFIED
so only DBAs can enable it. Within a session, the user calls SET ROLE role_name IDENTIFIED BY password
.
Create narrow, task-oriented roles. Grant only necessary privileges. Use WITH ADMIN OPTION
sparingly.Review roles regularly and revoke unused ones.
First, forgetting to grant privileges to the role—users get the role but no access. Second, failing to set the role as default—users must run SET ROLE
manually each session.
.
Yes. Grant the first role to the second with GRANT role_a TO role_b;
to build role hierarchies.
Query DBA_ROLE_PRIVS
for roles and ROLE_TAB_PRIVS
for object privileges granted to a role.