1. Create:
CREATE SEQUENCE emp_sequence --sequence name
INCREMENT by 1- -if omitted, the default is 1, and if negative, the value of the sequence is decremented by this step. Start
with 1 -counting the Nomaxvalue from 1- without setting the maximum nocycle-is cumulative and does not cycle
CACHE; --cache (buffering) defines the size of the memory block that holds the sequence, and defaults to 20.
2. Modify:
ALTER SEQUENCE sequence name
[INCREMENT by n]
[{maxvalue/minvalue n| Nomaxvalue}]
[{cycle| Nocycle}]
[{CACHE n| NoCache}];
* Cannot modify the initial value of the sequence
3. Delete
DROP SEQUENCE sequence name;
4. View all sequences
Select Sequence_name from Dba_sequences
SELECT * FROM User_sequences
5. Features:
is a database object provided by Oacle to produce a series of unique numbers.
L provide a unique numeric value automatically
L Shared objects
L primarily used to provide primary key values
L Loading sequence values into memory can improve access efficiency