Q) What is sequence ? Write and explain the syntax ‘CREATE SEQUENCE’ statements.
ANS: Sequence :-
·
A Sequence is a set of
integers (1,2,3…) that is used to generate a number sequence.
·
Sequence is useful when need
to create a unique number to act as a primary key.
·
The sequence of numeric values is generated in
ascending or descending order.
Syntax- CREATE SEQUENCE seq_name START WITH initial_val INCREMENT BY inc_val / DECREMENT BY
dec_value MAXVALUE max_val CYCLE / NOCYCLE ; |
Example-1 CREATE SEQUENCE seq_1 START WITH 1 INCREMENT BY 1 MAXVALUE 999 CYCLE ; |
§
INITIAL VALUE :- Specifies the starting value for the
sequence.
§
INCREMENT VALUE :- Value by which sequence will
be incremented.
§
MAXIMUM VALUE :- Specifies the upper limit / maximum value.
§
CYCLE :- Specifies that the value reaching either its MIN/MAXVALUE, sequence will restart its cycle from
begining.
§
NOCYCLE :- Specifies to indicate that the sequence can’t
generate more value after reaching its MIN/MAXVALUE.
0 Comments
If you have any suggestion or doubt, please ask me.
Emoji