We're creating a 'blank'/minimal copy of an existing database and want to reset one of the sequences to a value. Putting the number in the below works, but I want to make it reusable when sequence in the export has a higher number, trying to avoid dropping & recreating.
Can you do the equivalent of a subselect and calculation to get the value or does this need to be set as a variable 1st?
alter sequence users.SQ_USER_ID INCREMENT BY (99999 - select users.SQ_USER_ID.nextval from dual) nocache;
select users.SQ_USER_ID.nextval from dual;
alter sequence users.SQ_USER_ID INCREMENT BY 1 cache 20;
the aim being to end with the sequence at nextval as 99999.