Search Postgresql Archives

Re: Problem with unique key

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

 



Greg Peters wrote:
CSG=# \d admin_field_list
                                     Table "public.admin_field_list"
  Column    |            Type             |
Modifiers
-------------+-----------------------------+----------------------------------------------------------------
key         | bigint                      | not null default
nextval('admin_field_list_key_seq'::regclass)

*Now, as you can see, there is no field called "Kogan North", but when I
enter the command:*

CSG=# insert into admin_field_list (field, added_by) values ('Kogan North',
'Greg Peters');

ERROR:  duplicate key violates unique constraint "admin_field_list_pkey"

It's not complaining about "field" but about "key" - look at the constraint name. I'm guessing you've added rows with manual values for the "key" column. The sequence doesn't know about these, so is generating values already in use.

You can use setval(<sequence-name>) to update the sequence's value.

--
  Richard Huxton
  Archonet Ltd


[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