Sequence Ids are not updating after COPY operation in PostgreSQL

From: Siva Palanisamy <siva_p(at)hcl(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Sequence Ids are not updating after COPY operation in PostgreSQL
Date: 2012-02-01 06:38:20
Message-ID: 90F0F47595235141A4380FCF01B0185B2A1420C735@CHN-HCLT-EVS07.HCLT.CORP.HCL.IN
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there!

I'm inserting bulk records using COPY statement in PostgreSQL, and is successful. When I try to insert a record later manually, it throws duplicate sequence id error. What I realize is, the sequence ids are not getting updated in its cache. Should I manually update the sequence number to get the number of records after performing COPY? Isn't there a solution while performing COPY, just increment the sequence variable, that is, the primary key field of the table?

For instance, if I insert 200 records, COPY does good and my table shows all the records. When I manually insert a record later, it says duplicate sequence id error. It very well implies that it didn't increment the sequence ids during COPYing as work fine during normal INSERTing. Instead of instructing the sequence id to set the max number of records, won't there be any mechanism to educate the COPY command to increment the sequence ids during its bulk COPYing option?

Please clarify me on this. Thanks in advance!

Regards,
Siva.

________________________________
::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guillaume Lelarge 2012-02-01 07:50:09 Re: Sequence Ids are not updating after COPY operation in PostgreSQL
Previous Message Andrew Dunstan 2012-02-01 04:10:32 Re: [GENERAL] pg_dump -s dumps data?!