From: | Guillaume Lelarge <guillaume(at)lelarge(dot)info> |
---|---|
To: | Seb <spluque(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: \copy multiline |
Date: | 2012-11-29 09:33:37 |
Message-ID: | 1354181617.2124.17.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, 2012-11-28 at 21:21 -0600, Seb wrote:
> Hi,
>
> I use \copy to output tables into CSV files:
>
> \copy (SELECT ...) TO 'a.csv' CSV
>
> but for long and complex SELECT statements, it is cumbersome and
> confusing to write everything in a single line, and multiline statements
> don't seem to be accepted. Is there an alternative, or am I missing an
> continuation-character/option/variable that would allow multiline
> statements in this case?
>
A simple way to workaround this issue is to create a view with your
query and use the view in the \copy meta-command of psql. Of course, it
means you need to have the permission to create views in the database.
--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Gary Stainburn | 2012-11-29 10:14:27 | unique keys / foreign keys on two tables |
Previous Message | Seb | 2012-11-29 03:21:32 | \copy multiline |