DROP SEQUENCE

Function

DROP SEQUENCE deletes a sequence from the current database.

Precautions

Only the owner of a schema or a system administrator has the DROP SEQUENCE permission.

Syntax

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

Parameter Description

  • IF EXISTS

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

  • name

    Specifies the name of the sequence to be deleted.

  • CASCADE

    Automatically 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

-- Create an ascending sequence named serial, starting from 101.
postgres=# CREATE SEQUENCE serial START 101;

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

Helpful Links

ALTER SEQUENCE and DROP SEQUENCE

Feedback
编组 3备份
    openGauss 2025-05-30 22:42:36
    cancel