You can avoid the problem by changing the sequences as follows:
ALTER SEQUENCE XXX NOCACHE;
Actually "avoid the problem" means avoid the problem with sequence gaps.
But you cannot avoid the problem; there is no such thing as a gapless sequence. For example, even with nocache set if someone calls seq.nextval and doesn't insert the value somewhere (or does insert it and later rolls back their transaction) that number is gone.
Tamilselvan, Carlos : sorry for the delay, but the answer "HIGHWATER" given by Carlos is plain wrong : as said by HJR in the page that I cited (at the bottom of the page, read carefully) the correct answer is NEXTVALUE. My tests in a 9ir2 EE database :
sid=BDDEV:BDDEV:/u1/app/oracle>sqlplus /nolog
SQL*Plus: Release 9.2.0.5.0 - Production on Qua Jan 3 14:55:46 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn sys as sysdba
Enter password:
Connected.
==> user SCOTT have a sequence...
SQL> select nextvalue, min_value, max_value, cache_size, highwater from v$_sequences
2 where sequence_name='SEQ_DEPT' and sequence_owner='SCOTT';
scott@BDDEV:SQL>select SEQ_DEPT.nextval from dual;
NEXTVAL
------------------
23
==> yeah, 23 was the sequence next number, NEXTVAL in the sys object worked... letīs advance it :
scott@BDDEV:SQL>/
NEXTVAL
------------------
24
scott@BDDEV:SQL>/
NEXTVAL
------------------
25
scott@BDDEV:SQL>/
NEXTVAL
------------------
26
scott@BDDEV:SQL>/
NEXTVAL
------------------
27
scott@BDDEV:SQL>/
NEXTVAL
------------------
28
scott@BDDEV:SQL>/
NEXTVAL
------------------
29
scott@BDDEV:SQL>/
NEXTVAL
------------------
30
scott@BDDEV:SQL>/
NEXTVAL
------------------
31
scott@BDDEV:SQL>/
NEXTVAL
------------------
32
scott@BDDEV:SQL>/
NEXTVAL
------------------
33
scott@BDDEV:SQL>/
NEXTVAL
------------------
34
scott@BDDEV:SQL>/
NEXTVAL
------------------
35
scott@BDDEV:SQL>/
NEXTVAL
------------------
36
scott@BDDEV:SQL>/
NEXTVAL
------------------
37
scott@BDDEV:SQL>/
NEXTVAL
------------------
38
scott@BDDEV:SQL>
==> lets see the SYS object again :
SQL> l
1 select nextvalue, min_value, max_value, cache_size, highwater from v$_sequences
2* where sequence_name='SEQ_DEPT' and sequence_owner='SCOTT'
SQL> /
Yes, after a SHUTDOWN ABORT (or similar db stops) all in the caches is lost, this is one of the "issues" with it - and at a level, with v$ and the like, consistency do not plays a role here... If it fits the bill, use it, but using the value in NEXTVALUE not in HIGHWATER....
hi , why do the sequence numbers are missing if i use
cache option?
there is no shutdown abort, nor clearing the shared pool etc...
is there any possibility at users side i.e application side.??
if u suggest use NOCACHE option, then how to utilize cache option?
Bookmarks