Recently I had a question about sequences and their behavior when they are accessed concurrently by multiple users/sessions.
Surprisingly there is very little on this topic from Oracle (or for that matter on the web - search).
Minvalue: This is the minimum value that the sequence will generate.
Next Val,......) returning table_id into variable_name; (this forum post shows how returning keyword can be used when the row id is updated using an on insert-before trigger using an example -
You wouldn’t expect a sequence select to be a significant problem but recently we saw that it was—and in two different ways.
However when those cached values are exhausted the current sequence value must be written to disk (so duplicate values aren’t given upon restarts after instance crashes). The report would select a large number of rows and was using a sequence value and the NEXTVAL call to form a surrogate key. Well like most SQL tuning initiatives one of the best ways to tune a statement is to run it less frequently.
With SQL_ID 4m7m0t6fjcs5x that’s easy to accomplish by changing the sequence’s cache value.
You can use As an aside, if you are using a sequence to generate a record id and if you are trying to determine the last inserted rowid then you can use the returning keyword in Oracle.
eg: insert into table Name(table_id,.....) values (my Sequence.In our case, seeing SQL_ID 4m7m0t6fjcs5x as the top SQL statement quickly lead us to check the sequence settings and saw that almost all sequences had been created with the NOCACHE option.Therefore no sequence values were being cached and an update to SEQ$ was necessary after every single NEXTVAL call. Caching sequence values adds the risk of skipped values (or a sequence gap due to the loss of the cached values) when the instance crashes.Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).If you ever do data refreshes from production to development or test environments you may run into an issue where your sequences are not up to date.First some background (jump to the end if you wish to see my conclusion based on my research): CURRVAL and NEXTVAL (collated from various documents on the net) value of a sequence, the sequence is incremented immediately and permanently, whether you commit or roll back the transaction.