Re: select into ...outfile - Mailing list pgsql-novice

From Oliver Elphick
Subject Re: select into ...outfile
Date
Msg-id 1015025899.5762.864.camel@linda
Whole thread Raw
In response to select into ...outfile  (Clinton Adams <clinton@vote-smart.org>)
List 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.Elphick@lfix.co.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


pgsql-novice by date:

Previous
From: Clinton Adams
Date:
Subject: select into ...outfile
Next
From: "ebp"
Date:
Subject: Select statement question