Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hT8a5-000117-0K for pgsql-general@arkaria.postgresql.org; Tue, 21 May 2019 17:29:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hT8a3-0007y5-M8 for pgsql-general@arkaria.postgresql.org; Tue, 21 May 2019 17:29:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hT8a3-0007xy-9Y for pgsql-general@lists.postgresql.org; Tue, 21 May 2019 17:29:39 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hT8a1-0005N2-3X for pgsql-general@lists.postgresql.org; Tue, 21 May 2019 17:29:38 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id E009C99387 for ; Tue, 21 May 2019 10:29:35 -0700 (PDT) Date: Tue, 21 May 2019 10:29:35 -0700 (PDT) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: Bulk inserts into two (related) tables In-Reply-To: <823a98a6-1695-ed79-b460-0dd8a6257b0a@aklaver.com> Message-ID: References: <823a98a6-1695-ed79-b460-0dd8a6257b0a@aklaver.com> User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 21 May 2019, Adrian Klaver wrote: > The other way is to create the org_id for each organization ahead of time > and put it into the data file. Either way you have create the org_id for > the FK relationship, it is just a matter of where and when. Adrian, I had thought of that but overlooked it. The max(org_id) number is 338 so I can assign sequential numbers above that as I format the data for the insert scripts. Thanks for the reminder, Rich