Skip to main content
From the Postgresql Writer, when a table is truncated and then inserted with new data is it possible to reset the Primary Key sequence to '1'? It currently restarts at the last PK value (+1) from previous entry.

it looks possible, before writing/truncating you could do something like the following

https://stackoverflow.com/questions/4678110/how-to-reset-sequence-in-postgres-and-fill-id-column-with-new-data


Could you drop the table instead of truncating? I would think that should reset it to 1. Of course that might come with it's own set of headaches...


it looks possible, before writing/truncating you could do something like the following

https://stackoverflow.com/questions/4678110/how-to-reset-sequence-in-postgres-and-fill-id-column-with-new-data

Interesting option. I'll look in to that. Thanks.


Could you drop the table instead of truncating? I would think that should reset it to 1. Of course that might come with it's own set of headaches...

I could but there are going to be views associated to it so, as you said, "it's own set of headaches"...


it looks possible, before writing/truncating you could do something like the following

https://stackoverflow.com/questions/4678110/how-to-reset-sequence-in-postgres-and-fill-id-column-with-new-data

Worked perfectly.


Reply