From: | joseph speigle <joe(dot)speigle(at)jklh(dot)us> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Cannot insert a duplicate key into unique index |
Date: | 2004-06-04 03:40:43 |
Message-ID: | 20040604034043.GA18767@www.sirfsup.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
hi kj,
select nextval('shipments_ship_id_seq');
then add one to that, say it's now equal 1010 ...
SELECT setval('shipments_ship_id_seq', 1010);
source =
http://www.commandprompt.com/ppbook/index.lxp?lxpwrap=x14316%2ehtm#SETTINGASEQUENCEVALUE
but, sometimes there are deeper problems, as you alluded to.
On Thu, Feb 19, 2004 at 03:18:45PM +1100, Noel wrote:
> Hi KJ,
>
> For each SERIAL primary key, there is a sequence table for that table,
> which is where the primary key is generated. You need to check to see
> that the current counter in the sequence table is passed the MAX primary
> key in your table.
> eg:
> TABLE A
> id (pkey)
>
> Will have a sequence table
> A_id_seq
>
> Hope that helps
> Cheers
> Noel
>
> kynn(at)panix(dot)com wrote:
>
> >I'm trying to debug some problem in my database that is resulting in
> >an error of the form "Cannot insert a duplicate key into unique
> >index". The insert statement that is producing this error does not
> >include a value for the pkey field in question (this field is of type
> >SERIAL). I imagine that somehow the counter associated with this
> >field got messed up, so that it is mistakenly generating a value that
> >has been used already. How can I straighten it out?
> >
> >Thanks!
> >
> >kj
--
joe speigle
www.sirfsup.com
From | Date | Subject | |
---|---|---|---|
Next Message | Chris McCormick | 2004-06-04 13:33:50 | problem with pg_restore |
Previous Message | Joe Erickson | 2004-06-03 20:58:35 | Re: Executing sql script |