Re: dumping query results to a csv

From: Adi Alurkar <adi(at)sf(dot)net>
To: David Durham <ddurham(at)vailsys(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: dumping query results to a csv
Date: 2005-08-25 22:48:54
Message-ID: 8F4C1563-3FF3-419A-8156-41878BEEB890@sf.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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>]

HTH

Adi Alurkar
adi(at)sf(dot)net

On Aug 25, 2005, at 3:24 PM, David Durham wrote:

> This is kind of a pg-admin newbie question, so apologies in advance.
>
> Anyway, I'd like to issue a command that dumps the results of a
> query to
> a txt file in comma delimited format. Does PostgreSQL ship with
> something to do this? I searched the web, but found what appeared
> to be
> non-free solutions.
>
> Thanks,
>
> Dave
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Jeff Frost 2005-08-25 23:02:53 Re: dumping query results to a csv
Previous Message Jeff Frost 2005-08-25 22:34:46 Re: dumping query results to a csv