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 -> Re: ???? Reseting a sequence value ????

Re: ???? Reseting a sequence value ????

From: Arvind Balraman <dnivra_at_ix.netcom.com>
Date: 1998/03/03
Message-ID: <34FC4BF1.9FDEFAA2@ix.netcom.com>#1/1

assuming the sequence gives 221 as the nextval

SQL> select a.nextval from dual;

  NEXTVAL


       10

SQL> alter sequence a increment by -9
  2 ;

Sequence altered.

SQL> select a.nextval from dual;

  NEXTVAL


        1

why do u make the sequence to go to zero and increment 1

any particular reason???

--Arvind

Thomas Kyte wrote:

> A copy of this was sent to ilepper_at_fac.fbk.eur.nl (ilepper)
> (if that email address didn't require changing)
> On Mon, 2 Mar 1998 09:27:37 +0100, you wrote:
>
> >Is it possible to reset a sequence value back to 1 again?
> >So that when SEQ.NextVal will jump to 2.
> >
> >Anyway thanks,
> >
> >Ido de Lepper
> >ilepper_at_fac.fbk.eur.nl
>
> You can do it without dropping the sequence, consider:
>
> SQL> select myseq.nextval from dual;
>
> NEXTVAL
> ----------
> 221
>
> SQL> alter sequence myseq increment by -221 minvalue 0;
>
> Sequence altered.
>
> SQL> select myseq.nextval from dual;
>
> NEXTVAL
> ----------
> 0
>
> SQL> alter sequence myseq increment by 1;
>
> Sequence altered.
>
> SQL> select myseq.nextval from dual;
>
> NEXTVAL
> ----------
> 1
>
> SQL>
>
> Set the INCREMENT to be negative NEXTVAL, select it once and that'll reset it to
> zero, alter it to increment by 1 and the next select will get the original
> value.
>
> Thomas Kyte
> tkyte_at_us.oracle.com
> Oracle Government
> Herndon VA
>
> http://govt.us.oracle.com/ -- downloadable utilities
>
> ----------------------------------------------------------------------------
> Opinions are mine and do not necessarily reflect those of Oracle Corporation
>
> Anti-Anti Spam Msg: if you want an answer emailed to you,
> you have to make it easy to get email to you. Any bounced
> email will be treated the same way i treat SPAM-- I delete it.

--
Balaraman Arvind
151 Andrew Ave, Apt 215
Naugatuck, CT 06770

ph   -  (203)-723-1190(R)
     -  (203)-459-7502(O)

mail -  dnivra_at_ix.netcom.com (R)
        abalaram_at_oxhp.com    (O)
Received on Tue Mar 03 1998 - 00:00:00 CST

Original text of this message

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