Oracle sequence Learning
I. Create a sequence
Create sequence [user.] <sequence Name>
Increment by <growth value>
Start with <start value>
[Maxvalue <maximum value> | nomaxvalue]
[Minvalue <Minimum value> | nominvalue]
[Nocycle]
<Growth value> it can be positive or negative, but cannot be 0. If this clause is not available, the default value is 1;
<Start value> is the first value of the sequence.
Maxvalue indicates the maximum value of a sequence. If nomaxvalue is used, the maximum value of an ascending sequence is 1027, and the maximum value of a descending sequence is-1.
Minvalue indicates the minimum value of the sequence. If nominvalue is used, the minimum value of the ascending sequence is 1, and the minimum value of the descending sequence is-1026.
Nocycle does not have a cycle, so it keeps accumulating
Ii. Change the sequence
Alter sequence [user.] <sequence Name>
[Increment by <growth value>]
[Maxvalue <maximum value> | nomaxvalue]
[Minvalue <Minimum value> | nominvalue]
You can modify the sequence to modify the increment of future sequence values.
Sets or removes the minimum or maximum value.
Change the number of buffer sequences.
Specify whether the serial number is ordered.
Note:
1. The first NEXTVAL returns the initial value.
2. You can alter all sequence parameters except start. If you want to change the start value, you must drop sequence and re-create.
Iii. Delete sequence commands
Drop sequence [user.] <sequence Name>
Deletes a sequence from a database.
Author: "To_Be_Monster_Of_IT"