On this page
Warning:
CockroachDB v22.2 is no longer supported as of June 5, 2024. For more details, refer to the Release Support Policy.
The DROP SEQUENCE
statement removes a sequence from a database.
Note:
The DROP SEQUENCE
statement performs a schema change. For more information about how online schema changes work in CockroachDB, see Online Schema Changes.
Required privileges
The user must have the DROP
privilege on the specified sequence(s).
Synopsis
Parameters
Parameter | Description |
---|---|
IF EXISTS |
Drop the sequence only if it exists; if it does not exist, do not return an error. |
sequence_name_list |
A comma-separated list of sequence names. Find the sequence name with SHOW CREATE on the table that uses the sequence. |
RESTRICT |
(Default) Do not drop the sequence if any objects (such as constraints and tables) use it. |
CASCADE |
Not implemented. You can drop a sequence only if nothing depends on it. |
Examples
Remove a sequence (no dependencies)
In this example, other objects do not depend on the sequence being dropped.
> CREATE SEQUENCE even_numbers INCREMENT 2 START 2;
> SHOW SEQUENCES;
sequence_schema | sequence_name
------------------+----------------
public | even_numbers
(1 row)
> DROP SEQUENCE even_numbers;
> SHOW SEQUENCES;
sequence_schema | sequence_name
------------------+----------------
(0 rows)