How can I reset a sequence in Oracle?

1142290 pts.
Tags:
Oracle
PostgreSQL
Hello, Does anyone happen to know if I could reset a sequence in Oracle? I understand how to do it in PostgreSQL:
ALTER SEQUENCE serial RESTART WITH 0;
Thank you very much!
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

There is no way to reset it like that, but you can achieve the same result by setting an increment that is equal to the current value, but negative.  Then you have to get the current value once, and reset the increment to 1 (or whatever it was before).

Something like this (assuming a current value of 1420):

alter sequence seq increment by - 1420 minvalue 0;
select seq.nextval from dual;
alter sequence seq increment by 1;

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: