Re: duplicate key violates unique constraint

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: duplicate key violates unique constraint
Date: 2006-09-19 09:14:26
Message-ID: 450FB4F2.7000308@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ron Johnson wrote:

> # select * from projects;
> project_id | username | project_name
> - ------------+----------+--------------
> 1 | foo |
> 2 | bar |
> (2 rows)
>
> dupe_filenames=# insert into projects (project_name, username )
> dupe_filenames-# values ('foo', 'bar');
> ERROR: duplicate key violates unique constraint "projects_pkey"

And you didn't insert records with those numbers by hand (not using the
sequence)? It seems your sequence is a bit behind, which only happens if
you don't always use it to generate your ids.

I suggest you check your sequence values and update it to the highest
value in use if it's too low. You should only need to do that once.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrews, Chris 2006-09-19 09:51:21 Re: Oracle migration : size on disk of data file greater in PG
Previous Message Benoit.Gerrienne 2006-09-19 09:00:51 Oracle migration : size on disk of data file greater in PG