Re: copy query results to file - Mailing list pgsql-novice

From Thomas Kellerer
Subject Re: copy query results to file
Date
Msg-id jc9nca$20f$1@dough.gmane.org
Whole thread Raw
In response to copy query results to file  ("John Payne" <jcpayne@uw.edu>)
Responses Re: copy query results to file
List pgsql-novice
John Payne, 14.12.2011 02:49:
> 2.Use psql to output the data, as in:
>
> a.\o
>
> b.Query here….
>
> c.\o
>
> The psql produces output in an inconvenient format with pipe symbols and headers and underlines.

You can use the options:

\t
\a
\pset fieldsep ,

to get a more "CSV" like output in psql. If you want a tab character as the field delimiter, you can use:

\pset fieldsep '\t'

So the whole thing would be:

\a
\t
\pset fieldsep ,
\o

SELECT ...

\o

Thomas


pgsql-novice by date:

Previous
From: Pandu Poluan
Date:
Subject: Re: copy query results to file
Next
From: Michael Wood
Date:
Subject: Re: copy query results to file