Re: how do I capture conflicting rows - Mailing list pgsql-admin

From Mukesh Rajpurohit
Subject Re: how do I capture conflicting rows
Date
Msg-id CAL+ptAAH7Cd_-e43RsL17pTo4r2XQFyjG6DFBE2UaCri9eaXpg@mail.gmail.com
Whole thread Raw
In response to Re: how do I capture conflicting rows  (Scott Ribe <scott_ribe@elevated-dev.com>)
List pgsql-admin
Hi Nikhil,

After loading data in the target table query...
insert into temptable_conflictingrows (select * from sourcetable except select * from targettable_nonconflictingrows);

Thanks
Mukesh 

On Mon, May 15, 2023 at 6:48 PM Scott Ribe <scott_ribe@elevated-dev.com> wrote:
> On May 15, 2023, at 12:25 AM, Nikhil Ingale <niks.bgm@gmail.com> wrote:
>
> Thing is there is a list of tables (350+ tables) on which I'm running the insert query i.e., INSERT INTO table ON CONFLICT DO NOTHING to continue inserting the records by ignoring the conflicting rows. But, at the same time I would like to capture the conflicting rows or every single conflicting column (not just the PK's) and their values for every single table.

Create a "staging" table without constraints. Load all rows into it. Query for conflicts and report to user. Delete conflicting rows. Then INSERT INTO ... SELECT * FROM ...



pgsql-admin by date:

Previous
From: Scott Ribe
Date:
Subject: Re: how do I capture conflicting rows
Next
From: Jeff Janes
Date:
Subject: Re: Options for more aggressive space reclamation in vacuuming?