Reputation: 1875
When I created a sequence for a table article
, it's started from 17 not 1
CREATE SEQUENCE seq_article START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER auto_article BEFORE insert ON article
FOR EACH ROW
BEGIN
SELECT seq_article.NEXTVAL INTO :NEW.id_article FROM dual;
END;
/
I tried to delete all rows and creat other data, this time it's started from 19. How can I fix that?
Upvotes: 0
Views: 1066
Reputation: 231741
I'm not sure that I understand the problem.
CYCLE
and you exceed the MAXVALUE
(not realistically possible given the definition you posted) or you manually reset the sequence (say, by setting the INCREMENT BY
to -16, fetching a nextval
, and then setting the INCREMENT BY
back to 1), it won't ever generate a value of 1
a second time. Deleting the data has no impact on the next id_article
that will be generated.INSERT
operations which will massively decrease the scalability of your application.Upvotes: 1