Search Postgresql Archives

Re: Problem with unique key

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

 



ERROR:  duplicate key violates unique constraint "admin_field_list_pkey"
CSG=#

/I don't understand what is going on. It seems that it can't increment the primary key properly, or for some reason it's trying to assign an incorrect value to the key column. If i change the command to include a value for the key column (in this case the number 9), it seems to work. I've tried dumping/restoring the DB and also tried it on v8.1 and v8.2 with no success. Any ideas?/

Kind Regards,

Greg Peters.

The problem is in the primary key constraint, not the unique one. I guess you have inserted the previous rows with 'key' value specified directly just like in:

=# insert into admin_field_list (key, field, added_by) values (1, 'Talinga', 'Greg Peters');

Thus the sequence is not set to the correct value and generates values from 1 ... and these are already in the table. Try this

=# SELECT setval('admin_field_list_key_seq', (SELECT MAX(key) FROM
admin_field_list));

and then the insert again.

Tomas


[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