【oracle】重置oracle序列从指定数字开始

 

declare 
n number(10);
v_startnum number(10):=10000001;--从多少开始
v_step number(10):=1;--步进
tsql varchar2(200);
v_seqname varchar2(200):='MIP_JF_SEQUENCE';--序列名
begin
 execute immediate 'select '||v_seqname||'.nextval from dual' into n;
  n:=v_startnum-n-v_step;--从10000001开始
  tsql:='alter sequence '||v_seqname||' increment by '|| n;
  execute immediate tsql;
 execute immediate 'select '||v_seqname||'.nextval from dual' into n;
  tsql:='alter sequence '||v_seqname||' increment by '||v_step;
 execute immediate tsql;
end;
/

你可能感兴趣的:(oracle,序列,重置)