Skip to main content
The ALTER SEQUENCE applies a to a sequence.
The ALTER SEQUENCE statement performs a schema change. For more information about how online schema changes work in CockroachDB, see .

Required privileges

  • To alter a sequence, the user must be the owner of the sequence.
  • To change the schema of a sequence with ALTER SEQUENCE ... SET SCHEMA, the user must have the DROP on the sequence and the CREATE privilege on the new schema.
  • To rename a sequence with ALTER SEQUENCE ... RENAME TO, the user must have the DROP on the sequence and the CREATE privilege on the sequence’s database.

Syntax

alter_sequence syntax diagram

Parameters

Examples

Change the increment value of a sequence

In this example, we’re going to change the increment value of a sequence from its current state (i.e., 1) to 2.

Rename a sequence

In this example, we will change the name of sequence.

Change the schema of a sequence

Suppose you that you would like to add to a new schema called cockroach_labs:
By default, created in the database belong to the public schema:
If the new schema does not already exist, :
Then, change the sequence’s schema:

See also