Categories:

Table, View, & Sequence DDL

ALTER SEQUENCE

Modifies the properties for an existing sequence.

See also:

CREATE SEQUENCE , SHOW SEQUENCES

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 CREATE SEQUENCE.

SET...

[ INCREMENT [ BY ] sequence_interval

Specifies the step interval of the sequence:

  • For positive sequence interval n, the next n-1 values are reserved by each sequence call.

  • For negative sequence interval -n, the next n-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.

Examples

Rename sequence myseq to newseq:

ALTER SEQUENCE myseq RENAME TO newseq;