When a sequence is invoked for the first time, it returns a predetermined value, and in each subsequent query call, the sequence produces a value that is obtained by its specified increment.
1. Create sequence
The syntax format is as follows:
Create sequence [schema.] Sequence_name
[Increment by Incre_value]--each increment, by default, is 1*/
[start with Start_value]--Initial value */
[MaxValue Integer | Nomaxvalue]--Maximum value */
[minvalue integer | nominvalue]-min/
[cycle | nocycle]-cycle/
[Cache integer | NOCAC He]--buffer set/
[order | noorder]--serial number is generated in sequence * *
Sample code:
Create sequence mysequence increment by 2-start with 1;
2, the use of the sequence
After the sequence is created, a value is returned each time the Sequence_name.nextval is invoked.
Sample code:
Select Mysequence.nextval from dual;
2, modify the sequence
The syntax format is as follows:
Alter sequence [schema.] Sequence_name
[Increment by integer_value]
[MaxValue integer | nomaxvalue]
[MinValue integer | Nominvalue]
[cycle | nocycle]
[Cache integer | nocache]
[order | noorder]
Sample code:
Alter sequence mysequence increment by 1 MaxValue 1000;
3. Delete sequence
The syntax format is as follows:
Drop sequence sequence_name;
Sample code:
Drop sequence mysequence;
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/