Re: \copy multiline

From: Sebastian P(dot) Luque <spluque(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: \copy multiline
Date: 2012-11-29 15:35:13
Message-ID: 877gp4o21a.fsf@kolob.subpolar.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 29 Nov 2012 10:33:37 +0100,
Guillaume Lelarge <guillaume(at)lelarge(dot)info> wrote:

> 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.

Thanks. Someone also suggested creating a temporary view, which helps
keep the schema sane and clean.

Cheers,

--
Seb

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bert 2012-11-30 17:00:32 Can't get upsert working.
Previous Message Sebastian P. Luque 2012-11-29 15:31:10 Re: \copy multiline