Home  >  Article  >  Database  >  How to delete sequence in oracle

How to delete sequence in oracle

WBOY
WBOYOriginal
2022-05-13 15:35:047972browse

In Oracle, you can use "drop sequence sequence name" to delete sequence; sequence means automatically increasing the sequence of numbers, that is, the sequence number. The sequence number automatically increases and cannot be reset, so you need to use the drop sequence statement. to delete the sequence.

How to delete sequence in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to delete sequence in oracle

In Oracle, sequence is the so-called serial number. It will automatically increase every time it is taken. It is generally used in places that need to be sorted by serial number. The advantage is that it is accurate and efficient, but the disadvantage is that it cannot be reset and will continue to increase unless it is deleted and re-created;

Delete Sequence

Execute the following statement to achieve deletion

Oracle delete sequence: drop sequence xxxx

DROP SEQUENCE sequence_test; 
drop sequence student_id;

Extended knowledge:

Create Sequence

You must first have CREATE SEQUENCE Or CREATE ANY SEQUENCE permission, (usually all have this permission)

CREATE SEQUENCE sequence_test

  • INCREMENT BY 1 -- Add a few at a time

  • START WITH 1 -- Start counting from 1

  • ## MAXVALUE 99999999 --Maximum value (nomaxvalue can also be used--no maximum value)

  • MINVALUE 1--Minimum value (nominvalue can also be used--no minimum value)

  • NOCYCLE -- Keep accumulating, no looping

  • CACHE 10 -- cache 10 (nocache can also be used - no cache means no serial number is generated in memory in advance);

2. Use Sequence (CURRVAL, NEXTVAL)

CURRVAL = Return the current value of sequence

NEXTVAL = Increase the value of sequence, and then return the sequence value

SELECT sequence_test.NEXTVAL FROM DUAL;Achieve self-increment effect

SELECT sequence_test.CURRVAL FROM DUAL;View the current sequence value

Note: Where sequence can be used:

  • SELECT statement that does not include subqueries, snapshots, and VIEW

  • In the subquery of the INSERT statement

  • In the VALUES of the NSERT statement

  • In the SET of UPDATE

  • 3.Update Sequence

can modify multiple attributes, arranged in order. Can

ALTER sequence_test  MAXVALUE 10000  MINVALUE -300

Recommended tutorial: "

Oracle Video Tutorial"

The above is the detailed content of How to delete sequence in oracle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn