Sequence
A Sequence is a database object that generates unique numbers; mostly Sequence is used for the primary key values. A Sequence is an object in oracle database that used to generates the number Sequence and this number Sequence useful when you need to create a unique number which act as primary key.
The Sequence of number can be generates in either ascending or descending order.
Syntax:
Create sequence<sequence_name> increment by <integer> start with<integer>maxvalue <integer> minvalue<integer>cache<integer>;
CACHE: Cache the specified number of sequence values into buffer in the SGA. This speed access, but it lost when database shutdown. The default values is 20 and we give maximum value=maxvalue - minvalue.
Example:
Create sequence seq_1 minvalue1 maxvalue 99 start with 1 increment by 1 cache 20;
OR
Create sequence seq_2 increment by 1 start with 1 maxvalue 1000 minvalue 1 cache 20;
No comments:
Post a Comment