Question

I would like to how can I reset primary key counter in JDBC:Derby from code? I want it reset when I delete database records, but leave tables intact. When I do that, primary key counter does not reset and continue where it ended. I was thinking about something like this

ALTER SEQUENCE <tabname>_<id>_seq RESTART WITH 1

Will this work? And if yes will it work correctly?

Était-ce utile?

La solution

This is explained in the columnAlteration section of the ALTER TABLE statement section in the Derby Reference Manual.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top