GRANT (Sequence)
Grants privileges on a sequence generator to a user or role. Optionally grants privileges on all sequences within one or more schemas.
Syntax
GRANT { SELECT | ALL [ PRIVILEGES ] }... ON SEQUENCE [schema.]sequence-name[,...]
... | ON ALL SEQUENCES IN SCHEMA schema-name[,...]
... TO { username | role | PUBLIC }[,...]
... [ WITH GRANT OPTION ]
Parameters
SELECT |
Allows the right to use both the CURRVAL and NEXTVAL functions on the specified sequence. |
PRIVILEGES |
Is for SQL standard compatibility and is ignored. |
[db-name.]schema |
Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example: myschema.thisDbObject |
sequence-name |
Specifies the sequence on which to grant the privileges. When using more than one schema, specify the schema that contains the sequence on which to grant privileges. |
ON ALL SEQUENCES IN SCHEMA |
Grants privileges on all sequences within one or more schemas to a user and/or role. |
username |
Grants the privilege to the specified user. |
role |
Grants the privilege to the specified role. |
PUBLIC |
Grants the privilege to all users. |
WITH GRANT OPTION |
Allows the user to grant the same privileges to other users. |
Privileges
USAGE on the schema that contains the sequence
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