From: | Nikhil Ingale <niks(dot)bgm(at)gmail(dot)com> |
---|---|
To: | Ron <ronljohnsonjr(at)gmail(dot)com> |
Cc: | pgsql-admin(at)lists(dot)postgresql(dot)org |
Subject: | Re: how do I capture conflicting rows |
Date: | 2023-05-15 06:25:02 |
Message-ID: | CALXkTpxRGtUjH+GP67W_+fXahaUUmpTPE+LiLugF--_862PD-Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
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.
INSERT INTO TABLE ON CONFLICT DO NOTHING don't even report us on the
conflicting rows. How do I identify what the conflicting rows are by
continuing the inserts to happen even if there are any conflicts. I mean my
insert command shouldn't fail on conflicts but at the same time conflicts
should be reported to the user.
Regards,
Nik
On Mon, May 15, 2023 at 11:39 AM Ron <ronljohnsonjr(at)gmail(dot)com> wrote:
> 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.
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Ron | 2023-05-15 06:42:46 | Re: how do I capture conflicting rows |
Previous Message | Ron | 2023-05-15 06:09:24 | Re: how do I capture conflicting rows |