Re: Bulk inserts into two (related) tables

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Bulk inserts into two (related) tables
Date: 2019-05-21 18:28:58
Message-ID: alpine.LNX.2.20.1905211128160.6551@salmo.appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 21 May 2019, Will Hartung wrote:

> You can either use a script for the entire process, or, convert the people
> table to INSERT statements that have a SELECT for the foreign key as part
> of the insert.
>
> INSERT INTO PEOPLE (id, name, org_id) VALUES (1, ‘Bob’, (SELECT org_id
> FROM org WHERE org_name=‘Main Office’))

Thanks, Will. That's a good alternative.

Regards,

Rich

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-05-21 19:42:40 Re: Re: Refresh Publication takes hours and doesn´t finish
Previous Message Tom Lane 2019-05-21 18:27:33 Re: Re: Re: Refresh Publication takes hours and doesn´t finish