Re: Unique constraint violation on serial column - Mailing list pgsql-general

From Bill Chandler
Subject Re: Unique constraint violation on serial column
Date
Msg-id 20050412162154.70499.qmail@web51402.mail.yahoo.com
Whole thread Raw
In response to Unique constraint violation on serial column  (Bill Chandler <billybobc1210@yahoo.com>)
List 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@dcc.uchile.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[@]dcc.uchile.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/

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Unique constraint violation on serial column
Next
From: fritz-bayer@web.de (Fritz Bayer)
Date:
Subject: Re: Encoding Issue with UNICODE