Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> sequence omits numbers?

sequence omits numbers?

From: Norman Dunbar <Norman.Dunbar_at_lfs.co.uk>
Date: Tue, 5 Aug 2003 13:25:12 +0100
Message-ID: <E2F6A70FE45242488C865C3BC1245DA703FE1215@lnewton.leeds.lfs.co.uk>


Stephan,

First of all, a sequence CANNOT be used to build a complete set of numbers - because, sequnces can lose numbers under certain conditions.

consider the following :

create sequence testseq
order
cache 10;

The 'cache 10' says to Oracle, whenever the first number is requested from this sequence, stick the next 9 into the cache so that subsequent requests for numbers from this sequence will work much faster.

Unfortunately, when the database is closed down (shutdown abort, normal or immediate, or startup force) then all cahced values are lost. In addition, if the DBA flushes the shared pool, you lose the cached numbers as well.

You can pin the sequence in the SGA using SYS.DBMS_SHARED_POOL.KEEP('TESTSEQ','Q') (assuming that SYS has run the $ORACLE_HOME/rdbms/admin/dbmspool.sql script and granted your user (or PUBLIC) execute privs).

Now, you don't lose the cached numbers when the shared pool is flushed, or when the database is shutdown (normal or immediate) but you will still lose them if the database is shutdown abort or startup forced.

As I said, you cannot guarantee not to lose numbers from a sequence.

Cheers,
Norm.

PS. Startup force is equivalent to shutdown abort followed by startup. PPS. There is a thread on comp.database.oracle.server on sequences and pinning at present which might give further information.



Norman Dunbar
Database/Unix administrator
Lynx Financial Systems Ltd.
mailto:Norman.Dunbar_at_LFS.co.uk
Tel: 0113 289 6265
Fax: 0113 289 3146
URL: http://www.Lynx-FS.com

-------------------------------------
Received on Tue Aug 05 2003 - 07:25:12 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US