Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reset sequence to last used value

user13117585Mar 12 2022

Hello everyone,
I have a question. I can't find the syntax anymore. I hope someone could help here...
Imagine I have a table like this one:

CREATE TABLE foo
(
 id number GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 NOCACHE ORDER ), 
 name varchar2(100)
);
  
INSERT INTO foo(name) values('foo');
INSERT INTO foo(id, name) values(12, 'bar');

-- reset the identity and update to last value used in the id column.


 
INSERT INTO foo(name) values('bar');

I would like to reset the identity column and when I insert another record after the id 12, I would like to insert 13 and not 2.
If I'm not mistaken, there is a syntax for this but I can't find it anymore :( Even, in the documentation.

This post has been answered by Jonathan Lewis on Mar 12 2022
Jump to Answer
Comments
Post Details
Added on Mar 12 2022
4 comments
1,204 views