Search Postgresql Archives

Re: Problems inserting data into a table with a sequence

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

 



RNG <rgasch@xxxxxxxxx> writes:
> Trying to insert data into this table using the following SQL
> ...
> gives us the following error:
>  ERROR:  duplicate key violates unique constraint "pn_categories_category_pkey"

Usually the reason for this is that you inserted some rows with manually
assigned serial numbers (perhaps a COPY from an old version of the
table?) and forgot to advance the sequence past those numbers.  Try
something like

SELECT setval('pn_categories_category_cat_id_seq',
              (SELECT MAX(cat_id) + 1 FROM pn_categories_category));


			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[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