Re: Problems inserting data into a table with a sequence - Mailing list pgsql-general

From Tom Lane
Subject Re: Problems inserting data into a table with a sequence
Date
Msg-id 26029.1192489157@sss.pgh.pa.us
Whole thread Raw
In response to Problems inserting data into a table with a sequence  (RNG <rgasch@gmail.com>)
List pgsql-general
RNG <rgasch@gmail.com> 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

pgsql-general by date:

Previous
From: RNG
Date:
Subject: Problems inserting data into a table with a sequence
Next
From: "Merlin Moncure"
Date:
Subject: Re: Convert bytea to Float8