Skip to Main Content
  • Questions
  • How to change sequence.nextval increase amount

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, bhoges.

Asked: July 24, 2017 - 11:54 am UTC

Last updated: July 24, 2017 - 4:41 pm UTC

Version: 12c

Viewed 1000+ times

You Asked

i have table a

create table a (sno number(10));

create sequence test 
start with 1
increment by 1
nocycle
nocache;

insert into a (sno) values(test.nextval);


I have executed the above insert statement 1000 times.

now
 select max(sno) from a;

max(sno)
---------
1000


if I use the test sequence I need to insert the values like 1050, 1100,1150,

what should be the sequence modification for this.

Please let us know if any concerns.

thanks in advance.

Regards,
T.Bhogeswara Prasad.



and Chris said...

So you want to modify it so each call to the sequence jumps 50 values?

If so, just change the increment by to 50:

create table a (sno number(10));

create sequence test start with 999
 increment by 1 nocycle nocache;

insert into a (sno) values(test.nextval);
insert into a (sno) values(test.nextval);

alter sequence test increment by 50;

insert into a (sno) values(test.nextval);
insert into a (sno) values(test.nextval);
insert into a (sno) values(test.nextval);

select * from a;

       SNO
----------
       999
      1000
      1050
      1100
      1150


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.