Updated on 2024-06-03 GMT+08:00

DROP SEQUENCE

Description

Deletes a sequence from the current database.

Precautions

Only the owner of a sequence, the owner of the schema to which the sequence belongs, or a user granted the DROP permission on a sequence or a user granted the DROP ANY SEQUENCE permission can delete a sequence. When separation of duties is disabled, a system administrator has this permission by default.

Syntax

DROP SEQUENCE [ IF EXISTS ] { [schema.] sequence_name } [ , ... ] [ CASCADE | RESTRICT ];

Parameters

  • IF EXISTS

    Reports a notice instead of an error if the specified sequence does not exist.

  • sequence_name

    Specifies the name of the sequence to be deleted.

  • CASCADE

    Cascadingly deletes the objects that depend on the sequence.

  • RESTRICT

    Refuses to delete the sequence if any objects depend on it. This is the default action.

Examples

1
2
3
4
5
-- Create an ascending sequence named serial, starting from 101.
gaussdb=# CREATE SEQUENCE serial START 101;

-- Delete a sequence.
gaussdb=# DROP SEQUENCE serial;

Helpful Links

ALTER SEQUENCE and DROP SEQUENCE