---
title: "DROP SEQUENCE"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/ddl_drop_sequence/"
---

# DROP SEQUENCE

Use the DROP SEQUENCE statement to delete a sequence in the current schema.

## Synopsis

Use the DROP SEQUENCE statement to delete a sequence in the current schema.

## Syntax

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-1)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-1)

```output.ebnf
drop_sequence ::= DROP SEQUENCE [ IF EXISTS ] sequence_name 
                  [ CASCADE | RESTRICT ]
```

#### drop\_sequence

DROPSEQUENCEIFEXISTS[sequence\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#sequence-name)CASCADERESTRICT

## Semantics

### *sequence\_name*

Specify the name of the sequence.

- An error is raised if a sequence with that name does not exist in the current schema unless IF EXISTS is specified.
- An error is raised if any object depends on this sequence unless the CASCADE option is specified.

### CASCADE

Remove also all objects that depend on this sequence (for example a DEFAULT value in a table's column).

#### RESTRICT

Do not remove this sequence if any object depends on it. This is the default behavior even if it's not specified.

## Examples

Dropping a sequence that has an object depending on it, fails.

```plpgsql
yugabyte=# CREATE TABLE t(k SERIAL, v INT);
```

```output
CREATE TABLE
```

```plpgsql
\d t
```

```output
                           Table "public.t"
 Column |  Type   | Collation | Nullable |           Default
--------+---------+-----------+----------+------------------------------
 k      | integer |           | not null | nextval('t_k_seq'::regclass)
 v      | integer |           |          |
```

```plpgsql
yugabyte=# DROP SEQUENCE t_k_seq;
```

```output
ERROR:  cannot drop sequence t_k_seq because other objects depend on it
DETAIL:  default for table t column k depends on sequence t_k_seq
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
```

Dropping the sequence with the `CASCADE` option solves the problem and also deletes the default value in table `t`.

```plpgsql
yugabyte=# DROP SEQUENCE t_k_seq CASCADE;
```

```output
NOTICE:  drop cascades to default for table t column k
DROP SEQUENCE
```

```plpgsql
\d t
```

```output
                 Table "public.t"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 k      | integer |           | not null |
 v      | integer |           |          |
```

## See also

- [ALTER SEQUENCE](/stable/api/ysql/the-sql-language/statements/ddl_alter_sequence "ALTER SEQUENCE")
- [CREATE SEQUENCE](/stable/api/ysql/the-sql-language/statements/ddl_create_sequence "CREATE SEQUENCE")
- [currval()](/stable/api/ysql/exprs/sequence_functions/func_currval "currval()")
- [lastval()](/stable/api/ysql/exprs/sequence_functions/func_lastval "lastval()")
- [nextval()](/stable/api/ysql/exprs/sequence_functions/func_nextval "nextval()")
- [setval()](/stable/api/ysql/exprs/sequence_functions/func_setval "setval()")
