copy query results to file

From: "John Payne" <jcpayne(at)uw(dot)edu>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: copy query results to file
Date: 2011-12-14 01:49:05
Message-ID: 001f01ccba02$9159e3b0$b40dab10$@edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi, a very basic question here: I am using an older version of Postgresql
(8.1.11 running on Redhat Fedora 5.3) on a remote server that times me out
fairly quickly, and I need to run some queries that take a long time to
complete. Therefore I would like to story the query results in a file in a
.csv format. I see from the documentation that there are two basic
approaches:

1. Write a query using "COPY table TO 'file' CSV".

2. Use psql to output the data, as in:

a. \o

b. Query here..

c. \o

Neither approach is working for me. 1) The COPY query doesn't work on
views, and gives me an error when I try to run it as "COPY (select .). 2)
The psql produces output in an inconvenient format with pipe symbols and
headers and underlines.

Can anyone advise?

Thanks,

GK

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Pandu Poluan 2011-12-14 08:15:19 Re: copy query results to file
Previous Message Devrim GÜNDÜZ 2011-12-13 14:58:40 Re: pgagent linux 64bit