From: | Steve T <steve(at)retsol(dot)co(dot)uk> |
---|---|
To: | "Obe, Regina" <robe(dot)dnd(at)cityofboston(dot)gov> |
Cc: | PostGreSQL <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Flat File unload/export/copy |
Date: | 2008-09-12 16:10:17 |
Message-ID: | 1221235817.3603.203.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Regina,
I wasn't aware that you could!
I just tried and that syntax gave me an error:
rel_reinsure=# copy (select * from client where name like '%BERT%') to
'/tmp/stevet.clients';
ERROR: syntax error at or near "(" at character 6
LINE 1: copy (select * from client where name like '%BERT%') to '/tm...
- I can do though:
rel_reinsure=# copy client (recno,code,name) to '/tmp/stevet.clients';
... or select all columns, but that is 'too global' and I just want
'WHERE name LIKE '%BERT%' type syntax.
On Fri, 2008-09-12 at 11:31 -0400, Obe, Regina wrote:
> And why can't you use copy?
>
> Something like below -
>
> COPY (SELECT * FROM sometable WHERE somevalue LIKE '%') TO
> '/path/to/textfile.csv'
>
> WITH NULL As 'NULL' CSV HEADER QUOTE AS '"';
>
>
>
>
> ________________________________
>
> From: pgsql-novice-owner(at)postgresql(dot)org
> [mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of Steve T
> Sent: Friday, September 12, 2008 11:16 AM
> To: PostGreSQL
> Subject: [NOVICE] Flat File unload/export/copy
>
>
> Is there a command that copies data from a table to a flat file for
> specified selection criteria?
> IE akin to a copy but not dumping a whole file?
> If I'm about to do a major change to data in a table, I'd like to be
> able to keep a copy of the data before the change (I know I can
> Begin...rollback should things go wrong).
>
> Is there a command that I've missed? (Informix had an 'UNLOAD TO blah
> SELECT blah..' type command which presumably was proprietary).
> -----------------------------------------
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure
> pursuant to Massachusetts law. It is intended
> solely for the addressee. If you received this in error, please
> contact the sender and delete the material from any computer.
>
>
Steve Tucknott
ReTSol Ltd
DDI: 01323 488548
Mobile: 0773 671 5772
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Bax | 2008-09-12 17:11:03 | Re: Flat File unload/export/copy |
Previous Message | Obe, Regina | 2008-09-12 15:31:36 | Re: Flat File unload/export/copy |