Sequence Privileges
To create a sequence, a user must have CREATE privileges on a schema that contains the sequence. Only the owner and superusers can initially access the sequence. All other users must be granted access to the sequence by a superuser or the owner.
Only the sequence owner (typically the person who creates the sequence) or the superuser can drop or rename a sequence, or change the schema in which the sequence resides:
- DROP SEQUENCE: Only a sequence owner or schema owner can drop a sequence.
- ALTER SEQUENCE RENAME TO: A sequence owner must have USAGE and CREATE privileges on the schema that contains the sequence to be renamed.
- ALTER SEQUENCE SET SCHEMA: A sequence owner must have USAGE privilege on the schema that currently contains the sequence (old schema), as well as CREATE privilege on the schema where the sequence will be moved (new schema).
The following table lists the privileges that can be granted to users or roles on sequences.
The only privilege that can be granted to a user or role is SELECT, which allows the user to use CURRVAL() and NEXTVAL() on sequence and reference in table. The user or role also needs to have USAGE privilege on the schema containing the sequence.
Privilege | Description |
---|---|
SELECT |
Permission to use CURRVAL() and NEXTVAL() on sequence and reference in table. |
USAGE |
Permissions on the schema that contains the sequence. |
Note: Referencing sequence in the CREATE TABLE statement requires SELECT privilege on sequence object and USAGE privilege on sequence schema.
For details on granting and revoking sequence privileges, see GRANT (Sequence) and REVOKE (Sequence) in the SQL Reference Manual.