Syntax

Here is the generic syntax to drop a sequence number generator.

In PostgreSQL:

DROP SEQUENCE [ IF EXISTS ] [schema_name.]sequence_name [, ...] [ CASCADE | RESTRICT ];
  • CASCADE: Automatically drop objects that depend on the sequence, and in turn, all objects that depend on those objects.
  • RESTRICT: Refuse to drop the sequence if any objects depend on it. This is the default.

The RESTRICT option is used by default to make sure you cannot drop an object when another object depends on it. So if you use CASCADE instead, when dropping the sequence, all depending objects will also be deleted.

In SQL Server:

DROP SEQUENCE [ IF EXISTS ] [schema_name.]sequence_name [, ...];

In Oracle:

DROP SEQUENCE schema_name.sequence_name [, ...];

Example

Drop the sequence serial in current PostgreSQL database:

DROP SEQUENCE serial;

Need a good GUI tool for databases? TablePlus provides a native client that allows you to access and manage Oracle, MySQL, SQL Server, PostgreSQL, and many other databases simultaneously using an intuitive and powerful graphical interface.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS

TablePlus in Dark mode