·  SQL Role

 

- Info:

  - Roles are invented to avoid retypting the same grants to each of the users that should have the same priviliges.

  - Instead we give grants to each role only once and then we only define to which roles user belongs to.

 

- Grants:

  - To be able to create or delete role you need to be given following grants:

    GRANT CREATE ROLE TO myUser;

    GRANT DROP   ROLE TO myUser;

 

- Syntax – Create/Drop:

  - Role can be created or droped like this:

    CREATE ROLE AdminRole;

    DROP   ROLE AdminRole;

 

- Example:

  - This example shows how to create role, give it grants, add role to the users and finally delete role.

 

    CREATE ROLE AdminRole;

 

    GRANT  CREATE SESSION,

           CREATE TABLE,

           CREATE SEQUENCE,

           CREATE VIEW,

           CREATE PROCEDURE

    TO     AdminRole;

 

    GRANT  AdminRole TO user1, user2;

 

    DROP   ROLE AdminRole;