public inbox for [email protected]
help / color / mirror / Atom feedFrom: Rich Shepard <[email protected]>
To: [email protected]
Subject: Multiple tables row insertions from single psql input file
Date: Mon, 10 Jun 2024 11:50:27 -0700 (PDT)
Message-ID: <[email protected]> (raw)
My business tracking database has three main tables: company, location,
contact. The company and contact primary keys are sequences.
I've been adding new rows using INSERT INTO files separately for each table
after manually finding the last PK for the company and contact tables. The
location table has the company PK as a FK; the contact table has both
company PK and location PK as foreign keys.
Now I will use next_val 'PK' to assign the value for each new table row.
My question is whether I can create new rows for all three tables in the
same sql source file. Since the location and contact tables require sequence
numbers from the company and location tables is there a way to specify,
e.g., current_val 'tablename PK' for the related tables? Or, do I still need
to enter all new companies before their locations and contact?
TIA,
Rich
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Multiple tables row insertions from single psql input file
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox