Re: Check for duplicates before inserting new rows

From: George Woodring <george(dot)woodring(at)iglass(dot)net>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Check for duplicates before inserting new rows
Date: 2020-09-04 13:27:14
Message-ID: CACi+J=RChdQUTYNJ86aQC9YjHDL3DxSkv87W7zA5FDeDiRqNKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I would suggest creating a temp table based on the original table and
loading the data into it first. You can then purge the duplicates.

George Woodring
iGLASS Networks
www.iglass.net

On Fri, Sep 4, 2020 at 9:21 AM Rich Shepard <rshepard(at)appl-ecosys(dot)com>
wrote:

> This is a new issue for me: I've received data from a different source and
> need to add non-duplicates to two tables in the database. Each row in the
> new data has a station ID and associated measurements.
>
> The existing database includes a table for station information and another
> for measurements made there.
>
> I want to learn which stations and which measurements in the new data set
> are not included in the existing tables. And, I don't want to try inserting
> the new data and have postgres tell me when it's found duplicates,
> especially since there are two tables involved.
>
> My research into how to do this has not found a solution so I ask for
> pointers to resources that will teach me how to add these new data to both
> tables.
>
> Regards,
>
> Rich
>
>
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2020-09-04 14:40:00 Re: Check for duplicates before inserting new rows
Previous Message Rich Shepard 2020-09-04 13:21:10 Check for duplicates before inserting new rows