Re: select into ...outfile

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Clinton Adams <clinton(at)vote-smart(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: select into ...outfile
Date: 2002-03-01 23:38:19
Message-ID: 1015025899.5762.864.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, 2002-03-01 at 22:50, Clinton Adams wrote:
>
> I need to generate text files from queries. In mysql this was SELECT INTO
> OUTFILE. Is it a two step process with postgres - SELECT INTO TEMPORARY
> TABLE then COPY TABLE?

That will work, but you cannot do much with the formatting.

The most direct way for you to do what you want is to use \o OUTFILE
from psql. You can use other psql options to change the field
delimiters, if you want to export to a spreadsheet, for example; or you
can output in HTML or LaTeX format.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C

"The LORD is my shepherd; I shall not want. He maketh
me to lie down in green pastures: he leadeth me beside
the still waters, he restoreth my soul...Surely
goodness and mercy shall follow me all the days of my
life; and I will dwell in the house of the LORD for
ever." Psalms 23:1,2,6

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message ebp 2002-03-02 22:13:06 Select statement question
Previous Message Clinton Adams 2002-03-01 22:50:51 select into ...outfile