DB2 10.5 for Linux, UNIX, and Windows

GRANT (schema privileges) statement

This form of the GRANT statement grants privileges on a schema.

Invocation

This statement can be embedded in an application program or issued through the use of dynamic SQL statements. It is an executable statement that can be dynamically prepared only if DYNAMICRULES run behavior is in effect for the package (SQLSTATE 42509).

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 schema-name
  • ACCESSCTRL or SECADM authority

No user can grant privileges on schema names starting with SYSIBM, SYSCAT, SYSFUN, or SYSSTAT (SQLSTATE 42501).

Syntax

Read syntax diagramSkip visual syntax diagram
          .-,------------.                           
          V              |                           
>>-GRANT----+-ALTERIN--+-+--ON SCHEMA--schema-name-------------->
            +-CREATEIN-+                             
            '-DROPIN---'                             

       .-,---------------------------------.   
       V                                   |   
>--TO----+-+-------+--authorization-name-+-+-------------------->
         | +-USER--+                     |     
         | +-GROUP-+                     |     
         | '-ROLE--'                     |     
         '-PUBLIC------------------------'     

>--+-------------------+---------------------------------------><
   '-WITH GRANT OPTION-'   

Description

ALTERIN
Grants the privilege to alter or comment on all objects in the schema. The owner of an explicitly created schema automatically receives ALTERIN privilege.
CREATEIN
Grants the privilege to create objects in the schema. Other authorities or privileges required to create the object (such as CREATETAB) are still required. The owner of an explicitly created schema automatically receives CREATEIN privilege. An implicitly created schema has CREATEIN privilege automatically granted to PUBLIC.
DROPIN
Grants the privilege to drop all objects in the schema. The owner of an explicitly created schema automatically receives DROPIN privilege.
ON SCHEMA schema-name
Identifies the schema on which the privileges are to be granted.
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 name.
ROLE
Specifies that the authorization-name identifies a role name. The role name must exist 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 privileges to a set of users (authorization IDs). For more information, see "Authorization, privileges and object ownership".
WITH GRANT OPTION
Allows the specified authorization-names to GRANT the privileges to others.

Rules

Notes

Examples