6

Possible Duplicate:
How do I reset a sequence in Oracle?

I would like to change one parameter of sequence LAST_NUMBER to some number, how can i do it through SQL query.

ALTER SEQUENCE MSG_MESSAGE_SEQUENCE RESTART WITH 97

And it is not working.

2
  • 1
    If you want to increase the value, use a big increment (diff between desired and actual) for one nextval-call and then reset increment to real value: ALTER SEQUENCE mySeq INCREMENT BY 1000004; SELECT mySeq.nextval from dual; ALTER SEQUENCE mySeq INCREMENT BY 1; source: community.oracle.com/thread/2512696 For decreasing you can drop and recreate your sequence, it that is an option for you. Commented Apr 5, 2017 at 11:35
  • The correct syntax is: ALTER SEQUENCE MSG_MESSAGE_SEQUENCE RESTART START WITH 97; Commented Oct 25, 2021 at 14:03

1 Answer 1

1

From here:

'select MSG_MESSAGE_SEQUENCE.nextval from dual' INTO l_val;

execute immediate
'alter sequence ' || p_seq_name || ' increment by 97 - ' || l_val || ' minvalue 97';
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.