From: Rich Shepard <rshepard@appl-ecosys.com>
To: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: Check for duplicates before inserting new rows
Date: Fri, 4 Sep 2020 07:40:00 -0700 (PDT)
Message-ID: <alpine.LNX.2.20.2009040736090.7473@salmo.appl-ecosys.com> (raw)
In-Reply-To: <CACi+J=RChdQUTYNJ86aQC9YjHDL3DxSkv87W7zA5FDeDiRqNKQ@mail.gmail.com>
References: <alpine.LNX.2.20.2009040613450.7473@salmo.appl-ecosys.com>
<CACi+J=RChdQUTYNJ86aQC9YjHDL3DxSkv87W7zA5FDeDiRqNKQ@mail.gmail.com>
On Fri, 4 Sep 2020, George Woodring wrote:
> 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,
I hadn't thought of this. Using a duplicate table without a PK would work
well if there's only one attribute that needs checking.
In my case there are two tables involved: locations and measurements. So, I
can create a temporary table from the new data which holds only the
locations. I can then isolate the new location rows that do not already
exist in that table, then insert the new data to eliminate the duplicated
measurements.
Thanks,
Rich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: rshepard@appl-ecosys.com
Subject: Re: Check for duplicates before inserting new rows
In-Reply-To: <alpine.LNX.2.20.2009040736090.7473@salmo.appl-ecosys.com>
References: <alpine.LNX.2.20.2009040613450.7473@salmo.appl-ecosys.com> <CACi+J=RChdQUTYNJ86aQC9YjHDL3DxSkv87W7zA5FDeDiRqNKQ@mail.gmail.com> <alpine.LNX.2.20.2009040736090.7473@salmo.appl-ecosys.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox