Sequences:
Ø Sequences are a set of database objects, which can generate sequential integer value.
Ø They
are used to automatically generate primary key or unique key values.
Syntax:
Sequence_name:
Ø It
specifies the Name of the sequence.
Initial Value:
Ø Initial
Value Specifies
the first sequence number to be generated.
Ø It
should be greater than or equal to minimum value and less than equal to maximum
value.
ØIt specifies the interval between sequence numbers. This value can be any positive or negative but it cannot be 0.
Ø Ø If this value is negative then the sequence descends. If increment is positive, then the sequence ascends.
Minimum value:
Ø It
specifies the Minimum value of the sequence.
Maximum value:
Ø It
specifies the Maximum value of the sequence.
Cycle:
Ø It Specifies that the sequence continue to generate values after reaching either its maximum or minimum value.
Nocycle:
Ø It Specifies that the sequence cannot generate more values after reaching its maximum or minimum values. The default is NOCYCLE.
Cache:
Ø It Specifies how many values of the sequence oracle pre allocates and keeps in memory for faster access.
Nocache:
Ø It specifies that values of the sequence are not pre allocated. If you omit both the cache parameter and the NOCACHE option, Oracle caches 20 sequence numbers by default.
Example: 1
Sequence:
Table:
Products
Insertion:
ITEM_NO |
ITEM_NAME |
1 |
Book |
2 |
Pencil |
3 |
Bag |
The following specifications of a sequence can be
altered.
· Minimum value
· maximum value
· Incremental
value
· Number of cached
sequence number.
Alter Sequence:
Syntax:
Example:
Display the list of Sequences:
No comments:
Post a Comment