A sequence can be incremented (see Update sequence when out of synch) but in order to decrease the value of a sequence, it must be dropped and recreated with the following syntax:

drop sequence SEQUENCE_NAME;

CREATE SEQUENCE XXX_SEQ MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH YYY NOCACHE NOORDER NOCYCLE;


EXAMPLE:

drop sequence EO_SEQ;
create sequence EO_SEQ MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 11260 NOCACHE NOORDER NOCYCLE;


Following are instructions for dropping and recreating all sequences, as is necessary when copying an existing B5 instance in order to create a template for a non-standard conversion to B5:

Drop & recreate sequences so all sequences and hence PK ids begin at 1
GENERATE DROP SEQUENCE STATEMENTS:
set heading off
spool c:\temp\drop_sequences_generate.log
select 'drop sequence '||SEQUENCE_NAME||';' from user_sequences;
spool off


Copy file, rename as drop_sequences.sql, edit to delete select statement and add spool c:\temp\drop_sequences.log as first statement and spool off as last

GENERATE CREATE SEQUENCE STATEMENTS
spool c:\temp\create_sequences_generate.log
select 'create sequence '||SEQUENCE_NAME||' MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE;' from user_sequences;
spool off


Copy file, rename as create_sequences.sql, and edit to delete select statement, add spool c:\temp\create_sequences.log as first statement and spool off as last
Edit create_sequences.sql file so full statement on single line.

Perform a search for any sequences associated with extensible tables (EXT), verify the table no longer exists, and delete those create statements. Delete the extensible tables if they do exist.


Run drop_sequences.sql and create_sequences.sql
Review log files and fix any failutes
Verify sequences have been reset:
select sequence_name, last_number from user_sequences;


After data imported, run FIX_NEXT_SEQ;