What is a sequence?
A sequence is a database object used to generate a unique, contiguous integer. A sequence is typically used to automatically generate a value for a primary key or unique key. Sequences can be in ascending order or in descending order.
In fact, the sequence in Oracle is almost a meaning of self-growth in MySQL.
Create a sequence
Creates a sequence. Starting from the sequence Number 10, increase each time 1, the maximum is 2000, do not cycle, and then increase the error
CREATE SEQUENCE seq1
START with 10
INCREMENT by 1
MAXVALUE 2000
Nocycle
CACHE 30;
Access sequence
Access Next:
Seq1. Nextval
Query current:
SELECT seq1. Currval from dual;
Change sequence
ALTER SEQUENCE seq1
MAXVALUE 5000--Max 5000
CYCLE; --Cycle
Delete a sequence
DROP SEQUENCE seq1;
Using the Sys_guid function
SELECT Sys_guid () from dual;
Sequences in Oracle