Re: Strange primary key error on insertion - Mailing list pgsql-general

From Rory Campbell-Lange
Subject Re: Strange primary key error on insertion
Date
Msg-id 20111006135218.GD29101@campbell-lange.net
Whole thread Raw
In response to Re: Strange primary key error on insertion  (Filip Rembiałkowski <plk.zuber@gmail.com>)
List pgsql-general
On 06/10/11, Filip Rembiałkowski (plk.zuber@gmail.com) wrote:
> 2011/10/6 Rory Campbell-Lange <rory@campbell-lange.net>
> > => insert into s_tbls (select * from s_tbl_import);
> >
> >    ERROR:  duplicate key value violates unique constraint "s_tbls_pkey"
> >
> >
> Looks like you had duplicates in s_tbl_import. Try this:
> SELECT * FROM s_tbl_import WHERE n_id IN (
>     SELECT n_id from s_tbl_import group by n_id HAVING count(*)>1
> );

Hi Filip

You were right! Thanks for catching my silly error.

Rory

pgsql-general by date:

Previous
From: Vincent de Phily
Date:
Subject: Re: Never-idle autovacuum, and does (auto)vacuuming fill the OS cache ?
Next
From: David Johnston
Date:
Subject: Re: Selecting All Columns Associated With Maximum Value of One Column