Search Postgresql Archives

Re: Unique constraint violation on serial column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was able to get a pg_dump of the table in question. 
It has 23040 rows in it.  evt_id column ranges from 1
to 23040.  

I used the dump to create a new database.  All inserts
fail with same error (unique constraint violation). 
However,  I am wondering if this is just the result of
the fact that the pg_dump output conatins explicit
evt_id values for each row added so after creating the
database from the pg_dump output the sequence is still
at 1 when it should really be at 23040.  

How does one find out the current sequence value?  Is
there a way to change it?

Bill

--- Bill Chandler <billybobc1210@xxxxxxxxx> wrote:
> I'm sorry, was working on little sleep yesterday. 
> You
> are right, the table was created with the columns in
> the following order:
> 
> d1, obj_id, d2, val, correction, delta, evt_id
> 
> The insert command looks something like:
> 
> INSERT INTO EVENT_TBL VALUES(1039850293991, 145,
> 1039110343000, '10.25', 1, 739950991)
> 
> Bill
> 
> --- Ragnar Hafstað <gnari@xxxxxxxxx> wrote:
> > On Mon, 2005-04-11 at 11:03 -0700, Bill Chandler
> > wrote:
> > 
> > > ERROR: duplicate key violates unique constraint
> > > event_tbl_evt_id_key
> > 
> > > EVENT_TBL
> > > evt_id       bigserial, unique
> > > d1           numeric(13)
> > > obj_id       numeric(6)
> > > d2           numeric(13)
> > > val          varchar(22)
> > > correction   numeric(1)
> > > delta        numeric(13)
> > 
> > and a bit later , in response to a question,
> > On Mon, 2005-04-11 at 14:24 -0700, Bill Chandler
> > wrote: 
> > > Tom,
> > > 
> > > This is not the EXACT command (don't have that
> > since
> > > this a client site and they did not have logging
> > > turned on) but the insert command would have
> > looked
> > > something like:
> > > 
> > > INSERT INTO EVENT_TBL VALUES(1039850293991,
> > 'X.Y.Z',
> > > 1039110343000, '10.25', 1, 739950991)
> > 
> > firstly, the types do not seem to match the table
> > definition.
> > 
> > secondly, you seem to be inserting a literal value
> > into your
> > serial column.
> > 
> > did you mean to say that the insert was
> >   INSERT INTO EVENT_TBL (d1,...) VALUES (...) ?
> > 
> > what is the current value of the sequence ?
> > are there any rows there evt_id is higher than
> that
> > ?
> > 
> > gnari
> > 
> > 
> > 
> > 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faq
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux