Summary: in this tutorial, you will learn how to use the Oracle DROP SEQUENCE
statement to remove a sequence from the database.
Oracle DROP SEQUENCE overview
The DROP SEQUENCE
statement allows you to remove a sequence from the database.
Here is the basic syntax of the DROP SEQUENCE
statement:
DROP SEQUENCE schema_name.sequence_name;
Code language: SQL (Structured Query Language) (sql)
In this syntax, specify the name of the sequence that you want to remove after the DROP SEQUENCE
keywords.
If you don’t specify the schema to which the sequence belongs, Oracle will remove the sequence in your own schema.
The sequence that you remove must be in your own schema or you need to have the DROP ANY SEQUENCE
system privilege to remove a sequence in any schema.
The DROP SEQUENCE
statement is also useful in case you want to restart a sequence.
For example, if you have a sequence with the current value of 100 and you want to restart the sequence with a value of 50, then you can drop the sequence and re-create it with a START VALUE
of 50.
Oracle DROP SEQUENCE example
This statement creates a new sequence called no_seq
:
CREATE SEQUENCE no_seq;
Code language: SQL (Structured Query Language) (sql)
To remove the no_seq
from the database, you use the following statement:
DROP SEQUENCE no_seq;
Code language: SQL (Structured Query Language) (sql)
In this tutorial, you have learned how to use the Oracle DROP SEQUENCE
statement to remove a sequence from the database.