Re: Problem with unique key
От | Tomas Vondra |
---|---|
Тема | Re: Problem with unique key |
Дата | |
Msg-id | 456C0189.7080308@fuzzy.cz обсуждение исходный текст |
Ответ на | Problem with unique key ("Greg Peters" <gregpeters79@gmail.com>) |
Список | pgsql-general |
> 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
В списке pgsql-general по дате отправления: