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: A sequence problem

Re: A sequence problem

From: Roman Starek <starek_at_pluto.spsselib.hiedu.cz>
Date: 13 Mar 2001 09:53:26 GMT
Message-ID: <98kqmm$b0e$1@crax.cesnet.cz>

> Dear All,
 

> create sequence myseq increment by 1 nocycle nocache;
 

> select myseq.nextval into :new.col from dual;
 

> And assuming the last number of myseq is 123,
> May I change the last_number to 10?
> (for some reason i have to do it ,
> such like deleting rows from 11th to 123th)
>
> Is it possible? and how to?

Yes it is possible to do it withoud droping the sequence. You have only to alter sequence not to drop it.

You will need diference between old and new value and the way is.

alter sequence myseq increment by -10;
select myseq.nextval from dual;
alter sequence myseq increment by 1;

But it could be dangerous if somebody will use that sequence between two alter commands. So be aware of implicit commit in alter command.

        Starous Received on Tue Mar 13 2001 - 03:53:26 CST

Original text of this message

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