Creates a new role, extends an existing user to act as a role, or manages role administrators on a role.
CREATE [ OR REPLACE ] ROLE { role_name | FOR USER userID } [ WITH ADMIN [ ONLY ] admin_name [...,], [ SYS_MANAGE_ROLES_ROLE ]
When using the OR REPLACE clause, if an existing role administrator is included on the new role administrators list he or she retains his or her original administrative rights if they are higher than the replacement rights. For example, User A is an existing role administrator originally granted WITH ADMIN rights on the role. New role administrators are granted WITH ADMIN ONLY rights. If User A is included on this list, User A retains the higher WITH ADMIN rights.
CREATE ROLE Sales
CREATE OR REPLACE ROLE FOR USER Jane
CREATE ROLE Finance WITH ADMIN Mary, Jeff
CREATE ROLE Finance WITH ADMIN ONLY Mary, Jeff, SYS_MANAGE_ROLES_ROLE
This statement keeps Susan as an administrator, but Susan retains administrative rights to the role since the original administrative rights granted were higher. Harry is replaced by Bob and Sarah, with administrative rights only, and the global role administrator is added to the role. Harry remains a member of the role, but has no administrative rights.
CREATE OR REPLACE ROLE Finance WITH ADMIN ONLY Susan, Bob, Sarah, SYS_MANAGE_ROLE_ROLE
If you specify role administrators (admin_name), but do not include the global role administrator (SYS_MANAGE_ROLES_ROLE), global role administrators will be unable to manage the new role. Therefore, it is recommended that you not specify role administrators during the creation process. Use the OR REPLACE clause to add them afterwards.
If you do not specify an ADMIN clause, the default WITH ADMIN ONLY clause is used and the default administrator is the global roles administrator (SYS_MANAGE_ROLES_ROLE).
When replacing role administrators, if the role has a global role administrator, it must be included on the new role administrators list or it is removed from the role.
However, when using the WITH ADMIN clause to grant role administrators, since the clause is not valid for global role administrators, you must use the GRANT ROLE statement to re-add the global role administrator (SYS_MANAGE_RILES_ROLE) to the role. Failure to perform this grant means global role administrators are unable to manage the role.