To create Role on Oracle database,we use the CREATE ROLE SQL statement.
Example :
D:\app\Admin\virtual\virtual\product\12.2.0\dbhome_1\bin>sqlplus/nolog SQL*Plus: Release 12.2.0.1.0 Production on Sat Feb 19 15:05:32 2022 Copyright (c) 1982, 2016, Oracle. All rights reserved. SQL> conn sys/orcl@to_primary as sysdba Connected. ----Create a role named ab_dba SQL> create role ab_dba; Role created. ----Assign privileges to ab_dba role SQL> grant select any table to ab_dba; Grant succeeded. SQL> grant create any table to ab_dba; Grant succeeded. SQL> grant create any view to ab_dba; Grant succeeded. SQL> grant create synonym to ab_dba; Grant succeeded. SQL> grant create database link to ab_dba; Grant succeeded. -- Assign ab_dba role to a user named 'aman' SQL> grant ab_dba to aman; Grant succeeded. ---Assign ab_dba role to a user named 'mereba' SQL> grant ab_dba to mereba; Grant succeeded. SQL>
We can also use the REVOKE command to revoke a privilege from a role.
Example:
SQL> revoke ab_dba from aman; Revoke succeeded. SQL>
meda Changed status to publish 22/02/2022