Skip to main content
Multilingual TursoDB, MVCC & AI Agent database guides Read Engine Guide →
Turso Database SQL Reference Statements

DROP SEQUENCE

Remove a named sequence generator from the database

DROP SEQUENCE

NOTE

Turso Extension: DROP SEQUENCE is a Turso-specific statement not available in standard SQLite.

The DROP SEQUENCE statement removes a sequence object from the database. Once dropped, the sequence name can no longer be used with nextval(), currval(), or setval().

Syntax

DROP SEQUENCE [IF EXISTS] [schema-name.]sequence-name;

Description

DROP SEQUENCE removes the named sequence from the database schema. The sequence must exist unless the IF EXISTS clause is specified.

Clauses

Clause Description
IF EXISTS Suppresses the error that would occur if the sequence does not exist. The statement is a no-op when the sequence is not found.
schema-name The name of an attached database. Defaults to the main database if omitted.
sequence-name The name of the sequence to remove.

Examples

Drop a Sequence

CREATE SEQUENCE my_seq;
SELECT nextval('my_seq');
-- 1

DROP SEQUENCE my_seq;

SELECT nextval('my_seq');
-- Error: sequence "my_seq" does not exist

Drop with IF EXISTS

-- Safe to run even if the sequence does not exist
DROP SEQUENCE IF EXISTS nonexistent;

Recreate After Drop

Dropping and recreating a sequence resets it to its initial state:

CREATE SEQUENCE counter;
SELECT nextval('counter');
-- 1
SELECT nextval('counter');
-- 2

DROP SEQUENCE counter;
CREATE SEQUENCE counter;

SELECT nextval('counter');
-- 1

Errors

Error Cause
sequence "name" does not exist No sequence with that name exists and IF EXISTS was not specified.

See Also

Synced from official Turso documentation ( tursodatabase/turso-docs · MIT License) Official Docs ↗
Search
Press Esc to close · Powered by Pagefind