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

Home -> Community -> Usenet -> c.d.o.server -> Re: Problem with autosequence

Re: Problem with autosequence

From: HADDAD mohamed <m-haddad_at_calva.net>
Date: Wed, 06 Sep 2000 17:00:40 +0200
Message-ID: <39B65C18.192550CD@calva.net>

Hi,
The IDs doesn't increment by 1,
because Oracle uses a cache to generate values for a sequence, the default cache_size value is 20.
Each time you generate sequence values,
Oracle generates 20 values in the cache, values that are not used are lost.

You can change the cache_size value for a sequence, or don't use a cache :
alter sequence sequence_name nocache;

Bye

> <javah_at_njet.com> wrote in message news:8ooe4q$jqb$1_at_nnrp1.deja.com...

> > Hi.
> >
> > I am in trouble with the auto sequence.
> > I have multible tables in db. And each table has its sequence, eg.
> >
> > TABLE CREATED THIS WAY:
> >
> > create table test(
> > test_id number(20) primary key,
> > other_id number(20),
> > name varchar(128));
> >
> > SEQUENCE THIS WAY:
> >
> > create sequence test_id_seq
> > start with 1
> > increment by 1;
> >
> > And I add the information into the table this way:
> >
> > insert into test (test_id, order_id, name) values (test_id_seq.nextval,
> > 12, "asdf");
> >
> > Which works pretty nicely... But the ID doesn´t increment by 1 as it is
> > supposed to. Or doesn´t do it all the time by one. Sometimes the gap can
> > be about 20 sometimes 1... Sometimes something else. I haven´t got a
> > clue what defines the increment or why do some numbers get skipped.
> >
> > The whole insert sentence is constructed with some php code, yes. But
> > the name of the sequence and the name of the table is coming from
> > exactly the same variable, so if the variable is wrong the sentence
> > wouldn´t go thru anyway...
> >
> > Also the inserts are done thru web pages, so the connection is opened
> > and closed frequently, and it does seem a bit like the longer gaps comes
> > between every connection... Weird for me, but my Oracle knowledge is
> > limited. Might be possible that I have missed something vital here?
> > Maybe the sequence on its own is not enough???
> >
> > Help me out here, anyone who has more clue out of Oracle...
> >
> > -javah
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
Received on Wed Sep 06 2000 - 10:00:40 CDT

Original text of this message

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