Skip to Main Content
  • Questions
  • Oracle Sequence Cache x Numbers not always sequentially

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Peter.

Asked: September 01, 2017 - 10:28 am UTC

Last updated: September 01, 2017 - 3:08 pm UTC

Version: Oracle 11

Viewed 1000+ times

You Asked

Hello,

I would know if it is possible that a sequence with cache 20 generates a sequence, for instance now with value 235 and after an hour, generates a number minor than 235, 150 for example. I thought that sequence always generates numbers higher than the last value but in case of many sessions or bulk data inserts, could this issue occurs? I come across this yesterday because I order the table by id and I noticed that Id recently added is lower than the id added an hour before. Note: This table receives a lot of records due to a BDD process that set a lot if records (bulk data) before run the bdd tests. Maybe that why the issue mentioned occurs right?

Thank you!

and Chris said...

If you're using RAC this is entirely possible. Each instance caches its own set of numbers. So you can end up with values out-of-order.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.