February 15, 2019 at 10:13 am
#16925

Participant
You might have noticed that after bulk inserting records using the COPY statement in PostgreSQL the sequence IDs are not getting updated for any further inserts later on, and it would throw duplicate sequence ID errors.
So you would be wondering what makes this COPY statement different that it does not update the sequences,Don’t forget to update the sequence in PostgreSQL after a COPY command.
Use Below anyone of command to update the postgres sequence after bulk insertion or after COPY TO command.
ALTER SEQUENCE ehis.citymaster_seq RESTART WITH 649328;
SELECT setval('ehis.citymaster_seq', 649328);
SELECT setval('ehis.citymaster_seq', 649328);