GRANT (Sequence)

Grants sequence privileges to users and roles.

Syntax

GRANT privilege
   ON { 
     SEQUENCE [[database.]schema.]sequence[,…] 
     | ALL SEQUENCES IN SCHEMA [database.]schema[,…] }
   TO grantee[,…] 
   [ WITH GRANT OPTION ]

Parameters

privilege

One of the following:

  • SELECT: Grantees can execute functions CURRVAL and NEXTVAL on the specified sequences.
  • ALL [PRIVILEGES]:  Grants all sequence 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.

sequence

The sequence on which to grant privileges.

ALL SEQUENCES IN SCHEMA schema

Grants privileges on all sequences in the specified schema.

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. For details, see How to Grant Privileges in the Administrator's Guide.

Privileges

One of the following:

Examples

This example shows how to grant user Joe all privileges on sequence my_seq.

=> CREATE SEQUENCE my_seq START 100;
CREATE SEQUENCE
=> GRANT ALL PRIVILEGES ON SEQUENCE my_seq TO Joe;
GRANT PRIVILEGE

See Also