ALTER SEQUENCE
Changes the attributes of an existing sequence. All changes take effect in the next database session. Any parameters not set by an ALTER SEQUENCE
statement retain their previous settings.
Syntax

ALTER SEQUENCE [schema.]sequence-name ... [ INCREMENT [ BY ] increment-value ] ... [ MINVALUE minvalue | NO MINVALUE ] ... [ MAXVALUE maxvalue | NO MAXVALUE ] ... [ RESTART [ WITH ] restart‑value ] ... [ CACHE value | NO CACHE ] ... [ CYCLE | NO CYCLE ]

ALTER SEQUENCE [schema.]sequence-name { ... RENAME TO new-name ... | SET SCHEMA new-schema-name] ... | OWNER TO new-owner-name }
Parameters
schema |
Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example: myschema.thisDbObject If you do not specify a schema, the table is created in the default schema. |
sequence‑name |
The name of the sequence to alter. The name must be unique among sequences, tables, projections, and views. |
|
Renames a sequence within the same schema. To move a named sequence, use |
OWNER TO new‑owner‑name
|
Reassigns the current sequence owner to the specified owner. Only the sequence owner or a superuser can change ownership, and reassignment does not transfer grants from the original owner to the new owner (grants made by the original owner are dropped). |
SET SCHEMA new‑schema‑name
|
Moves a named sequence between schemas. |
INCREMENT [BY] increment‑value
|
Modifies how much to increment or decrement the current sequence to create a new value. A positive value increments an ascending sequence, and a negative value decrements the sequence. |
|
Modifies the minimum value a sequence can generate. If you change this value and the current value exceeds the range, the current value is changed to the minimum value if increment is greater than zero, or to the maximum value if increment is less than zero. |
|
Modifies the maximum value for the sequence. If you change this value and the current value exceeds the range, the current value is changed to the minimum value if increment is greater than zero, or to the maximum value if increment is less than zero. |
RESTART [WITH] restart-value |
Changes the current value of the sequence to restart‑value. The next call to Caution: Using |
|
Modifies how many sequence numbers are preallocated and stored in memory for faster access. The default is 250,000 with a minimum value of 1. Specifying a value of 1 indicates that only one value can be generated at a time, since no cache is assigned. Alternatively, you can specify NO CACHE. |
CYCLE | NO CYCLE |
Specifies whether the sequence can wrap when its minimum or maximum values are reached:
|
Privileges
- To rename a schema: sequence owner and USAGE and CREATE privileges on the schema.
- To move a named sequence between schemas: sequence owner and USAGE privilege on the schema that currently contains the sequence (old schema) and CREATE privilege on new schema to contain the sequence.
Examples
See Altering Sequences and Changing Sequence Ownership in the Administrator's Guide.