Creating Sequences:
CREATE SEQUENCE command is used to create the sequences. The syntax is used for creating Sequences is:
Syntax:
CREATE SEQUENCE <SEQUENCENAME>
[<INCREMENT BY> <VALUE>
<START WITH> <VALUE>
<MINVALUE> <VALUE>
<MAXVALUE> <VALUE>
<CACHE> <VALUE>
<CYCLE> <VALUE>
where,
INCREMENT BY :- this Specifies the interval among 2 integers. Can be a positive or negative value but it would not zero.
START WITH - this Specifies the first sequence number to be provided.
MINVALUE - this Indicates the minimum value in the sequence It must be less than or equal to START WITH and less than MAXVALUE.
MAXVALUE - this Specifies the maximum value the sequence can generate.
CYCLE - this denotes that sequence continues to generate values after reaching maximum values.
CACHE - this Specifies how several values must be kept in memory for faster access.
Example
CREATE SEQUENCE s1
START WITH 1
MINVALUE 1
INCREMENT BY 1
MAXVALUE 20
CYCLE CACHE 15;
Displays,
Sequence Created.