title: Oracle sequence caching
body: <p>I am trying to implement a sequence in an Oracle database to act as a surrogate key creator for a table.  For performance reasons, I want this sequence to be cached.  I have read that there are potential pitfalls when using cached sequences since rollbacks and instance failures will result in missed values.</p>
  
  <p>This got me to thinking.  Let's say I create a sequence with a cache size of 100.  Then I make a 50 record insert to my table, with the sequence value as the primary surrogate key.  After the commit, the current value of the sequence would not yet have been written to disk.  Suppose I were to have an instance failure at this point.  When the database comes back up, it is my understanding that the current sequence value will be reset to the last value written to disk.</p>
  
  <p>If I were to try inserting another 50 records into my table, will I now break the primary key constraint because the sequence was reset to its last state from disk and primary keys are now getting reused?  If this is the case, how would I prevent this?</p>