DB2 10.5 for Linux, UNIX, and Windows

GRANT (global variable privileges) statement

This form of the GRANT statement grants one or more privileges on a created global variable.

Invocation

This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.

Authorization

The privileges held by the authorization ID of the statement must include at least one of the following authorities:
  • The WITH GRANT OPTION for each identified privilege on the global variable
  • ACCESSCTRL or SECADM authority

Syntax

Read syntax diagramSkip visual syntax diagram
                 .-PRIVILEGES-.                                  
>>-GRANT--+-ALL--+------------+-+--ON--VARIABLE--variable-name-->
          | .-,---------.       |                                
          | V           |       |                                
          '---+-READ--+-+-------'                                
              '-WRITE-'                                          

       .-,---------------------------------.                          
       V                                   |                          
>--TO----+-+-------+--authorization-name-+-+--+-------------------+-><
         | +-USER--+                     |    '-WITH GRANT OPTION-'   
         | +-GROUP-+                     |                            
         | '-ROLE--'                     |                            
         '-PUBLIC------------------------'                            

Description

ALL PRIVILEGES
Grants all privileges on the specified global variable.
READ
Grants the privilege to read the value of the specified global variable.
WRITE
Grants the privilege to assign a value to the specified global variable.
ON VARIABLE variable-name
Identifies the global variable on which one or more privileges are to be granted. The variable-name, including an implicit or explicit qualifier, must identify a global variable that exists at the current server and is not a module variable (SQLSTATE 42704).
TO
Specifies to whom the privileges are granted.
USER
Specifies that the authorization-name identifies a user.
GROUP
Specifies that the authorization-name identifies a group.
ROLE
Specifies that the authorization-name identifies an existing role at the current server (SQLSTATE 42704).
authorization-name,...
Lists the authorization IDs of one or more users, groups, or roles. The list of authorization IDs cannot include the authorization ID of the user issuing the statement (SQLSTATE 42502).
PUBLIC
Grants the specified privileges to a set of users (authorization IDs).
WITH GRANT OPTION
Allows the specified authorization-name to grant the privileges to others. If the WITH GRANT OPTION clause is omitted, the specified authorization-name cannot grant the privileges to others unless that authority has been received from some other source.

Rules

Notes

Example

Grant the READ and WRITE privilege on global variable MYSCHEMA.MYJOB_PRINTER to user ZUBIRI.
   GRANT READ, WRITE ON VARIABLE MYSCHEMA.MYJOB_PRINTER TO ZUBIRI