Oracle does not let you change the value of a sequence. If you need to change its value, you should re-create the sequence. On the other hand, we can use a trick to change the value of a sequence without recreating it.
Let’s say we have a sequence and its value is 1000, and we want to set it to 500.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
CREATE SEQUENCE gokhan.sample_seq START WITH 1000; SELECT last_number FROM user_sequences WHERE sequence_name = 'SAMPLE_SEQ'; LAST_NUMBER ----------- 1000 ALTER SEQUENCE gokhan.sample_seq INCREMENT BY -500; SELECT gokhan.sample_seq.NEXTVAL FROM dual; ALTER SEQUENCE gokhan.sample_seq INCREMENT BY 1; SELECT last_number FROM user_sequences WHERE sequence_name = 'SAMPLE_SEQ'; LAST_NUMBER ----------- 500 |

