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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top