pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sebastian P. Luque <spluque@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: \copy multiline
Date: Thu, 29 Nov 2012 09:35:13 -0600
Message-ID: <877gp4o21a.fsf@kolob.subpolar.dyndns.org> (raw)
In-Reply-To: <1354181617.2124.17.camel@localhost.localdomain>
References: <87r4ndnlfn.fsf@kolob.subpolar.dyndns.org>
	<1354181617.2124.17.camel@localhost.localdomain>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On Thu, 29 Nov 2012 10:33:37 +0100,
Guillaume Lelarge <guillaume@lelarge.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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (5+ messages)

Message-ID: <877gp4o21a.fsf@kolob.subpolar.dyndns.org>
Permalink:  ../877gp4o21a.fsf@kolob.subpolar.dyndns.org/
Also on:    postgresql.org/message-id/877gp4o21a.fsf@kolob.subpolar.dyndns.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: spluque@gmail.com
  Subject: Re: \copy multiline
  In-Reply-To: <877gp4o21a.fsf@kolob.subpolar.dyndns.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox