From: Jim C. Nasby <jnasby@pervasive.com>
To: Adi Alurkar <adi@sf.net>
Cc: David Durham <ddurham@vailsys.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: dumping query results to a csv
Date: Thu, 25 Aug 2005 18:04:38 -0500
Message-ID: <20050825230438.GB11282@pervasive.com> (raw)
In-Reply-To: <8F4C1563-3FF3-419A-8156-41878BEEB890@sf.net>
References: <430E4536.3030203@vailsys.com>
<8F4C1563-3FF3-419A-8156-41878BEEB890@sf.net>
On Thu, Aug 25, 2005 at 03:48:54PM -0700, Adi Alurkar wrote:
> Greetings,
>
> There is no direct way to achieve what you want, the easiest hack is
> to create a temp table with you query i.e.
>
> create table tmp_foo as select col1, col4, col7 from table1, table2
> where ....;
> copy table tmp_foo to [stdout|<file_name>]
Can we make this a TODO? It would certainly be handy to be able to COPY
directly from a query.
In the mean time, you can also do something like
SELECT field1 || ',' || field2 || ',' || field3
and capture the output of that to a file, but that's an uglier hack than
the temptable trick.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com
Pervasive Software http://pervasive.com 512-569-9461
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: jnasby@pervasive.com, adi@sf.net, ddurham@vailsys.com
Subject: Re: dumping query results to a csv
In-Reply-To: <20050825230438.GB11282@pervasive.com>
References: <430E4536.3030203@vailsys.com> <8F4C1563-3FF3-419A-8156-41878BEEB890@sf.net> <20050825230438.GB11282@pervasive.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox