Re: how do I capture conflicting rows

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: how do I capture conflicting rows
Date: 2023-05-15 06:09:24
Message-ID: 34308ba9-6033-6e57-f44e-500b2ca9cad5@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 5/15/23 00:32, Nikhil Ingale wrote:
> Hi All,
>
> The following query inserts the rows by ignoring the rows that has conflicts.
>
> INSERT INTO test (id,name,age,branch) SELECT * FROM student ON CONFLICT DO
> NOTHING;
>
> How do I capture the conflicting records to a file while non conflicting
> records are inserted to the table?

On conflict insert the PK into a separate table, along with a timestamp
column populated by clock_timestamp().  (That way you can export and delete
sets of records while it's being written to.

--
Born in Arizona, moved to Babylonia.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Nikhil Ingale 2023-05-15 06:25:02 Re: how do I capture conflicting rows
Previous Message Nikhil Ingale 2023-05-15 05:32:00 how do I capture conflicting rows