Md. Naushad Alam
Md. Naushad Alam

Reputation: 8461

How oracle sequence works internally?

I wan to know how sequence for a table works internally in oracle database. Specially how they increment value of sequence.

Are they use trigger for incrementing value of sequence or anything else???

Upvotes: 1

Views: 1962

Answers (1)

Yury Nebieridze
Yury Nebieridze

Reputation: 71

Oracle does not handle sequences as other objects, like tables. If you insert 100 records using the NEXTVAL and issue a ROLLBACK, this sequence does not get rolled back. Instead, 100 records will have incremented the sequence. The next insert will have the 101-st value of the sequence. This will lead to "spaces" in the sequence. That allows for multiple people to safely use sequences without the risk of duplicates. If two users simultaneously grab the NEXTVAL, they will be assigned unique numbers. Oracle caches sequences in memory. The init.ora parameter SEQUENCE_CACHE_ENTRIES defines the cache size.

Upvotes: 3

Related Questions