Updated on 2025-02-27 GMT+08:00

DROP SEQUENCE

Description

Drops a sequence from the current database.

Precautions

  • Only the owner of a sequence, the owner of the schema of the sequence, or users granted with the DROP permission on the sequence can drop the sequence. By default, system administrators have the permission to drop the sequence.
  • If the LARGE identifier is used when a sequence is created, the LARGE identifier must be used when the sequence is dropped.

Syntax

DROP [ LARGE ] 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 dropped.

  • CASCADE

    Automatically drops the objects that depend on the sequence.

  • RESTRICT

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

Examples

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

-- Drop a sequence.
openGauss=# DROP SEQUENCE serial;

Helpful Links

ALTER SEQUENCE and DROP SEQUENCE