It is possible to reset a sequence in Oracle. The company does not provide a ready-made command for this task. However, it is possible to reset it by following the instructions below.
CREATE SEQUENCE seq;, search for its current value via the command:
SEQ.CURRVAL SELECT FROM DUAL;
ALTER SEQUENCE SEQ INCREMENT by -VAL;
SEQ.NEXTVAL SELECT FROM DUAL;
ALTER SEQUENCE SEQ INCREMENT by 1;
SQL> create sequence seq;
Sequence created.
SQL> select seq.nextval from dual;
NEXTVAL
----------
1
SQL> select seq.nextval from dual;
NEXTVAL
----------
2
SQL> select seq.nextval from dual;
NEXTVAL
----------
3
SQL> select seq.currval from dual;
CURRVAL
----------
3
SQL> alter sequence seq increment by -2; // 2=SEQ.CURRVAL-1
Sequence altered.
SQL> select seq.nextval from dual;
NEXTVAL
----------
1
SQL> alter sequence seq increment by 1;
Sequence altered.
DON'T MISS