Re: Unique constraint violation on serial column

From: Bill Chandler <billybobc1210(at)yahoo(dot)com>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unique constraint violation on serial column
Date: 2005-04-12 16:21:54
Message-ID: 20050412162154.70499.qmail@web51402.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

All,

In the pg_dump output is the command:

COPY event_tbl (d1, ..., evt_id) FROM stdin;

followed by all the data for the table. There are
23040 rows. The last value for evt_id is 23040. So
far so good. Then the last statement in the pg_dump
output is:

SELECT pg_catalog.setval('event_tbl_evt_id_seq',
21232, true);

I'm guessing this is my culprit. But this dump is
from the client site. Short of somebody mucking with
the sequence manually, is there any way that the
sequence number could get changed?

As I've said, our insert commands are very simple and
we do not specify 'evt_id' values directly. Does
anybody have any ideas about how this could have
gotten out of sync?

thanks,

Bill

--- Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> wrote:
> On Tue, Apr 12, 2005 at 08:48:15AM -0700, Bill
> Chandler wrote:
>
> > How does one find out the current sequence value?
> Is
> > there a way to change it?
>
> Using the function setval() you can change it.
> SELECT * from
> sequencename to find out.
>
> --
> Alvaro Herrera (<alvherre[(at)]dcc(dot)uchile(dot)cl>)
> "Si quieres ser creativo, aprende el arte de perder
> el tiempo"
>


__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

Browse pgsql-general by date

  From Date Subject
Next Message Santharam 2005-04-12 17:27:34 Suitable Database version
Previous Message Alvaro Herrera 2005-04-12 16:04:08 Re: Unique constraint violation on serial column