9.7.5.1 GRANT PRIVILEGE

Purpose

The GRANT PRIVILEGE command sets the access privileges for a role.

Syntax

GRANT PRIVILEGE { ALL ACTIONS | action } ON { ALL OBJECTS | object }   \
{ ALL ATTRIBUTES | ATTRIBUTES attribute1 [, attribute2, ...] }         \
{ WITH ALL OPTIONS | WITH OPTIONS option1 [, option2, ...] }           \
TO ROLE { ALL | role1 [, role2, ...] }

Usage Notes

  • action is the command. Examples: ALTER, CREATE, DESCRIBE, DROP, EXPORT, IMPORT, LIST.

    Notes:

    • The GRANT and REVOKE commands cannot be granted.
    • CREATE USER and DROP USER cannot be granted.

    • CREATE ROLE and DROP ROLE cannot be granted.

  • object is object type for the action. It can be any DBMCLI object. Examples: DBSERVER, THRESHOLD, PHYSICALDISK, ALERTHISTORY, ROLE.

  • attribute are the attributes for the object. To get a list of attributes for an object, run the LIST object_type command.

  • option are the options for the object. Examples: DETAIL, LIMIT, ORDER BY, WHERE.

  • role is the name of the role to grant privileges.

  • The ALL ACTIONS argument grants privileges for all actions.

  • The ALL OBJECTS argument grants privileges for all objects.

  • The ALL ATTRIBUTES argument grants privileges for all attributes.

  • The WITH ALL OPTIONS argument grants privileges for all options.

  • Specifying attributes and WITH OPTIONS is optional. If they are not specified, then all attributes and options are granted with the privilege.

Examples

Example 9-54 Granting Privileges to a Role

This example shows how to grant privileges to a role.

DBMCLI> GRANT PRIVILEGE list on alerthistory ATTRIBUTES alertAction,alertMessage  \
        WITH OPTIONS detail TO ROLE dbmonitor

Example 9-55 Granting All Attributes and Options to a Role

This example shows how to grant all attributes and options for a specified action and object to a role.

DBMCLI> GRANT PRIVILEGE { ALL ACTIONS | action } ON { ALL OBJECTS | object } to ROLE role1

Example 9-56 Granting All Options with Specified Action, Object and Attributes

This example shows how to grant all options with a specified action, object and attributes to a role.

DBMCLI> GRANT PRIVILEGE { ALL ACTIONS | action } ON { ALL OBJECTS | object }  \
ATTRIBUTES attribute1 [, attribute2, ...] to ROLE role1

Example 9-57 Granting All Attributes with Specified Action, Object and Options

This example shows how to grant all attributes with a specified action, object, and options to a role.

DBMCLI> GRANT PRIVILEGE { ALL ACTIONS | action } ON { ALL OBJECTS | object }   \
WITH OPTIONS option1 [, option, ...] to ROLE role1