Re: Process for populating tables in new database

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Process for populating tables in new database
Date: 2018-12-01 14:40:01
Message-ID: 3f660180-3ee0-84ef-6668-021d5c8ed347@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/1/18 6:09 AM, Rich Shepard wrote:
> I have a new database with five tables, and text files with data to
> populate
> the tables using the insert command.
>
> 1. Each table has a sequential primary key. Should I manually add keys to
> each insert row or will postgres generate it automatically? Example, for
> the
> companies table:
>
> org_id    | integer               |           | not null |
> nextval('companies_org_id_seq'::regclass)
> org_name  | character varying(64) |           | not null |
>
> 2. Should I use sepatate files as input to each table or can I combine them
> in a single file? For example, adding a company name and contact name for
> someone in that company using input commands for both tables in a single
> file? I will need to provide the primary key to the company table as the
> foreign key in contact table and have not before pupulated multiple related
> tables in a new database from .sql files.

Forgot to add that if you pre-assign the keys to the serial field you
will need to advance the sequence to a value past the last key value to
avoid a duplicate key error when you let the sequence assign numbers.

>
> TIA,
>
> Rich
>
>
>
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2018-12-01 15:32:27 Re: Process for populating tables in new database [RESOLVED]
Previous Message Adrian Klaver 2018-12-01 14:30:24 Re: Process for populating tables in new database