Re: selective export for subsequent import (COPY)

From: "Harvey, Allan AC" <HarveyA(at)OneSteel(dot)com>
To: "chrisj" <chrisj(dot)wood(at)sympatico(dot)ca>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: selective export for subsequent import (COPY)
Date: 2007-04-19 05:55:50
Message-ID: E97A5BB7699CAD48BE2711E71247116553715B@ntlmsg03.onesteel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris,

> I know about: psql dbname -tc "select * from tableX where whatever" >
> tableX.dat

What about
psql $DATABASEHOST -U $DATABASEUSER -d $DATABASE -q -P footer -A -F , -c "$DETAIL_SQL" >table.csv

To produce a comma separated file of tuples only.
If I'm not mistaken, as happens quite a bit, you can then use COPY to import the csv file.

Allan

The material contained in this email may be confidential, privileged or copyrighted. If you are not the intended recipient, use, disclosure or copying of this information is prohibited. If you have received this document in error, please advise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses contained in this email or any attachments.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2007-04-19 06:41:46 Re: Login to Postgres 8.2 via Cygwin hangs
Previous Message A. Kretschmer 2007-04-19 05:27:55 Re: selective export for subsequent import (COPY)