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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top