CREATE ROLE Statement

Creates a new role, extends an existing user to act as a role, or manages role administrators on a role.

Quick Links:

Go to Parameters

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

CREATE [ OR REPLACE ] ROLE { role_name | FOR USER userID }
   [ WITH ADMIN [ ONLY ] admin_name [...,], [ SYS_MANAGE_ROLES_ROLE ]

Parameters

(back to top)

Examples

(back to top)

Usage

(back to top)

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.

Standards

(back to top)

ANSI SQL–Compliance level: Transact-SQL extension.

Permissions

(back to top)