GRANT (Library)

Grants usage privileges on one or more libraries to users and roles.

For example, when working with the Connector Framework Service, you might need to grant a user usage privileges to a library to be able to set UDSession parameters. For more information see Implementing CFS.

Syntax

GRANT { USAGE | ALL [ PRIVILEGES ] }  | 
   ON LIBRARY [[database.]schema.]library[,…] 
   TO grantee[,…]
   [ WITH GRANT OPTION ]

Parameters

USAGE

Enables grantees access to functions in the specified libraries.

To execute functions inside the library, users must also have separate EXECUTE privileges on them, and USAGE privileges on their respective schemas.

ALL [PRIVILEGES]

Grants all library privileges that also belong to the grantor. Grantors cannot grant privileges that they themselves lack.

The optional keyword PRIVILEGES conforms with the SQL standard.

[database.]schema

Specifies a schema, by default public. If schema is any schema other than public, you must supply the schema name. For example:

myschema.thisDbObject

If you specify a database, it must be the current database.

library

The target library.

grantee

Specifies who is granted privileges, one of the following:

WITH GRANT OPTION

Gives grantee the privilege to grant the same privileges to other users or roles, and also revoke them. For details, see Granting Privileges.

Privileges

Non-superusers require USAGE on the schema and one of the following:

  • Owner
  • Privileges grantee given the option (WITH GRANT OPTION) of granting privileges to other users or roles.

Example

Grant USAGE privileges on the MyFunctions library to Fred:

=> GRANT USAGE ON LIBRARY MyFunctions TO Fred;