Re: problem importing data with psql

From: Richard Huxton <dev(at)archonet(dot)com>
To: chandresh rana <chandresh(dot)rana(at)metrixline(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: problem importing data with psql
Date: 2007-06-26 17:44:55
Message-ID: 46815097.30700@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Talha Khan 2007-06-26 17:49:02 Re: A problem in inheritance
Previous Message Tom Lane 2007-06-26 17:30:41 Re: a JOIN on same table, but 'slided over'