Search Postgresql Archives

Re: duplicate key violates unique constraint

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

 



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@xxxxxxxxxxxxxxxxx

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 //


[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