Oracle resets the self-increment sequence to the initial value of 1 o'clock, and if it is removed and rebuilt, then the functions and stored procedures that depend on it are invalidated and need to be recompiled. The inverse process is used to change the increment value to (sequence) using the negative step parameter. Nextval-1), and then change back. Suppose you need to modify the sequence name: Seq_name1、SelectSeq_name.nextval fromDual//Assuming results are 56562、AlterSequence Seq_name increment by -5655;//Attention is-(n-1)3、SelectSeq_name.nextval fromDual//check again, walk, reset to 1.4、AlterSequence Seq_name increment by 1;//Restore the following is the stored procedure, incoming sequence name:CREATE OR REPLACE PROCEDURESeq_reset (v_seqnameVARCHAR2) asN Number(Ten); TSQLVARCHAR2( -);BEGIN EXECUTEIMMEDIATE'Select' ||V_seqname|| '. Nextval from dual' intoN; N:= -(N- 1); TSQL:= 'Alter sequence' ||V_seqname|| 'Increment by' ||N; EXECUTEIMMEDIATE TSQL; EXECUTEIMMEDIATE'Select' ||V_seqname|| '. Nextval from dual' intoN; TSQL:= 'Alter sequence' ||V_seqname|| 'Increment by 1'; EXECUTEIMMEDIATE TSQL;ENDSeq_reset;
Oracle Reset Sequence