Showing posts with label alter sequence. Show all posts
Showing posts with label alter sequence. Show all posts

1.18.2018

How to reset Postgres Primary Key Sequence?

In Postgres auto incrementing primary keys are defined using SERIAL PRIMARY KEY. These primary keys are tied to a sequence when defined and hence we need to ALTER the sequence . . .

ALTER SEQUENCE ca_kw_kw_id_seq RESTART WITH 1;
UPDATE ca_kw SET kw_id=nextval('ca_kw_kw_id_seq');