Search Postgresql Archives

Re: dynamic crosstab

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes, once I have the select outputting it to CSV is not a problem. As you say PG handles that nicely.

Thx
SWK

-----Original Message-----
From: Reece Hart [mailto:reece@xxxxxxxxx] 
Sent: Wednesday, February 13, 2008 9:39 PM
To: Tino Wildenhain
Cc: SunWuKung; pgsql-general@xxxxxxxxxxxxxx
Subject: Re:  dynamic crosstab

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


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux