Sequences are frequently used in databases because many applications require each row in a table to contain a unique value and sequences provide an easy way to generate them
How to find sequences in SQL:
Syntax: desc user_sequences;
How to create the sequence:
Syntax:
CREATE SEQUENCE schema_name
[INCREMENT BY interval]
[START WITH the first number]
[MAXVALUE max value | NOMAXVALUE]
[MINVALUE min value | NOMINVALUE]
[CYCLE | NOCYCLE]
[CACHE cache size | NOCACHE]
[ORDER | NOORDER];
Ex:
Create Table
Now, Create a sequence
Sequence created with conditions needs to be performed.
To See sequence’s current value:
Syntax: select seq_name.currvalue from dual;
Ex:
How to Alter sequence:
Syntax: Alter sequence seq_name
(conditions…….);
Ex:
How to Drop Sequence:
Syntax: Drop sequence sequence_name
Ex:
Thank you for giving your valuable time to read the above information.
If you want to be updated with all our articles send us the Invitation or Follow us: