From: | Reece Hart <reece(at)harts(dot)net> |
---|---|
To: | Tino Wildenhain <tino(at)wildenhain(dot)de> |
Cc: | SunWuKung <Balazs(dot)Klein(at)t-online(dot)hu>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: dynamic crosstab |
Date: | 2008-02-13 20:39:29 |
Message-ID: | 1202935169.6510.43.camel@snafu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2008-02-13 at 14:04 +0100, Tino Wildenhain wrote:
> Well after all you want a CSV not a table. You could shortcut this
> with a generic query which creates array out of your "columns"
> and join them to a CSV line. This would just be outputted as
> one single column from database.
Depending on your use case, this may be a better way:
In psql:
=> \copy (select col1,col2,col3 from data) TO data.csv CSV HEADER
or on the command line:
$ psql -c '\copy (select col1,col2,col3 from data) TO data.csv CSV HEADER'
Strictly speaking, the CSV formatting isn't being done in the database
but rather by psql.
-Reece
--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Smith | 2008-02-13 20:44:57 | PostgreSQL 8.3 on Debian, Ubuntu |
Previous Message | Koen Vermeer | 2008-02-13 19:53:49 | Re: Storing images as BYTEA or large objects |