'return false;'

Pages

Thursday, December 30, 2010

Sequence

What is a sequence?
A sequence is nothing but a number generator in sequence as the name says. It could be used for generating unique keys alone and concatenating to other field values.
How to create a sequence?
Create sequence seq01
Start with 1
Increment by 1
Maxvalue 100
Nocycle
Cache 20
Usage:
Sequence is initialized when the user calls Seq01.nextval.
Questions:
1. What will be the output if user tries to use Seq01.currval before Sequence is initialized?
Error: ORA-08002: Sequence SEQ01.CURRVAL is not yet initialized in this session.
2. What will be the output of Seq01.nextval when Sequence is initialized?
Start value of the sequence. Here it is 1
3. How to change sequence attibutes?
All sequence attributes could be changed even after it is created and used.
Eg: Alter sequence seq01 increment by 1000
Alter sequence seq01 nocache
Alter sequence seq01 cycle
Alter sequence seq01 maxvalue 1000

No comments: