Re: copy query results to file

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: copy query results to file
Date: 2011-12-14 08:40:36
Message-ID: jc9nca$20f$1@dough.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Wood 2011-12-14 10:37:29 Re: copy query results to file
Previous Message Pandu Poluan 2011-12-14 08:17:45 Re: copy query results to file