Re: duplicate key violates unique constraint - Mailing list pgsql-general

From Alban Hertroys
Subject Re: duplicate key violates unique constraint
Date
Msg-id 450FB4F2.7000308@magproductions.nl
Whole thread Raw
In response to Re: duplicate key violates unique constraint  (Ron Johnson <ron.l.johnson@cox.net>)
List 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@magproductions.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 //

pgsql-general by date:

Previous
From: "Dave Page"
Date:
Subject: Re: vista
Next
From: Benoit.Gerrienne@BULL.BE
Date:
Subject: Oracle migration : size on disk of data file greater in PG