Monday, 17 June 2019

SQL Tutorial : SEQUENCE

SQL Tutorial : SEQUENCE

Let's learn about next topic: SEQUENCE


SEQUENCE:
***********

- UNIQUE VALUE GENERATOR:

10  STARTS WITH 10
20 INCREMENT BY 10
30 MAX VALUE 50
40  MIN VALUE 10
50  


- CREATE SEQUENCE SEQ;

- CREATE SEQUENCE SEQ1
START WITH 10
INCREMENT BY 10
MAXVALUE 50
NOCYCLE
CACHE 20


FUNCTIONS:
- NEXTVAL => GIVES THE NEXT GENERATED VALUE
- CURRVAL => POINTS TO VALUES GENERATED RECENTLY

- INSERT SEQ_TABLE
VALUES(SEQ1.NEXTVAL,'A')


- ALTER SEQUENCE SEQ1
INCREMENT BY 5
MAXVALUE 100


- ALTERING A SEQUENCE CHANGE THE FUTURE GENERATED NUMBERS

ONLY.

** START WITH CANNOT BE ALTERED

- SELECT SEQ.NEXTVAL FROM DUAL


DD: USER_SEQUENCES

Dropping a Sequence:

DROP SEQUENCE SEQ1

No comments:

Post a Comment