Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Sequences - Can we rollback a sequence [duplicate]

I am using oracle 11g . i came across creating sequences, it raised a question

Is it possible to rollback a sequence using java?

If we can , pls suggest me ?

like image 441
Santhosh Avatar asked Mar 22 '26 20:03

Santhosh


1 Answers

Yes, use alter sequence. See http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_2011.htm.

But note there is no real use for this. Unless you delete all records from your tables that use your sequence, you'll get errors when you use the sequence for creating unique IDs.

And you will always have "holes" in your generated numbers, there is no point in trying to make IDs created by sequences contiguous. Imagine user A doing an insert, user B doing another insert, user B commits, user A rolls back. The sequence number that A used will be lost, as B used a higher one.

like image 72
Guntram Blohm Avatar answered Mar 24 '26 10:03

Guntram Blohm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!