- Categories:
ALTER SEQUENCE¶
Modifies the properties for an existing sequence.
- See also:
Syntax¶
ALTER SEQUENCE [ IF EXISTS ] <name> RENAME TO <new_name>
ALTER SEQUENCE [ IF EXISTS ] <name> [ SET ] [ INCREMENT [ BY ] [ = ] <sequence_interval> ]
ALTER SEQUENCE [ IF EXISTS ] <name> SET COMMENT = '<string_literal>'
ALTER SEQUENCE [ IF EXISTS ] <name> UNSET COMMENT
Parameters¶
name
Specifies the identifier for the sequence to alter. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.
RENAME TO new_name
Specifies the new identifier for the sequence; must be unique for the schema.
For more details, see Identifier Requirements.
When an object is renamed, other objects that reference it must be updated with the new name.
SET...
[ INCREMENT [ BY ] sequence_interval ]
Specifies the step interval of the sequence:
For positive sequence interval
n
, the nextn-1
values are reserved by each sequence call.For negative sequence interval
-n
, the nextn-1
lower values are reserved by each sequence call.Supported values are any value that can be represented by a 64-bit two’s compliment integer.
0
is not allowed as a sequence interval.COMMENT = 'string_literal'
Adds a comment or overwrites an existing comment for the sequence.
UNSET ...
Specifies the properties to unset for the role, which resets them to the defaults.
Currently, the only property you can unset is
COMMENT
, which removes the comment, if one exists, for the sequence.
Usage Notes¶
The first/initial value for a sequence cannot be changed after the sequence is created.
Moving a sequence to a managed access schema (using the ALTER SEQUENCE … RENAME TO syntax) is prohibited unless the sequence owner (i.e. the role that has the OWNERSHIP privilege on the sequence) also owns the target schema.