Re: problem importing data with psql - Mailing list pgsql-general

From Richard Huxton
Subject Re: problem importing data with psql
Date
Msg-id 46815097.30700@archonet.com
Whole thread Raw
In response to problem importing data with psql  (cha <chandresh.rana@metrixline.com>)
List pgsql-general
chandresh rana wrote:
> Hi Richard,
>
> I have eliminated certain tables while exporting as they the size of the
> data in the tables are huge.Am having the schema of all the tables.
>
> Now want to import certain set of records/rows from the eliminated tables.
>
> Is it possible to do that ?? If yes, then can you please tell me how I can
> accomplish this?

The only practical way would be to process the rows outside the
database, perhaps in a Perl script or similar. Pipe COPY-format data
dumps through your script and have it strip out unwanted lines as it
feeds them to psql.

Otherwise, you'll have to import all the rows and then delete the ones
you want.

> How postgresql take care of all the constraints/referential integrity while
> importing the records from the different tables?

It won't do anything different with a standard COPY vs inserting rows
normally. You'll probably want to turn off constraints and indexes and
then re-apply them after the import.

Is there a good reason why you're not using pg_dump/pg_restore for this?

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: a JOIN on same table, but 'slided over'
Next
From: "Talha Khan"
Date:
Subject: Re: A problem in inheritance