X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7B31FD6F4D for ; Thu, 25 Aug 2005 20:04:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21425-07 for ; Thu, 25 Aug 2005 23:04:35 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 564AAD6E67 for ; Thu, 25 Aug 2005 20:04:35 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 5287C152BB; Thu, 25 Aug 2005 18:04:38 -0500 (CDT) Date: Thu, 25 Aug 2005 18:04:38 -0500 From: "Jim C. Nasby" To: Adi Alurkar Cc: David Durham , pgsql-admin@postgresql.org Subject: Re: dumping query results to a csv Message-ID: <20050825230438.GB11282@pervasive.com> References: <430E4536.3030203@vailsys.com> <8F4C1563-3FF3-419A-8156-41878BEEB890@sf.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8F4C1563-3FF3-419A-8156-41878BEEB890@sf.net> X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.012 required=5 tests=[AWL=0.012] X-Spam-Level: X-Archive-Number: 200508/330 X-Sequence-Number: 18649 On Thu, Aug 25, 2005 at 03:48:54PM -0700, Adi Alurkar wrote: > Greetings, > > There is no direct way to achieve what you want, the easiest hack is > to create a temp table with you query i.e. > > create table tmp_foo as select col1, col4, col7 from table1, table2 > where ....; > copy table tmp_foo to [stdout|] Can we make this a TODO? It would certainly be handy to be able to COPY directly from a query. In the mean time, you can also do something like SELECT field1 || ',' || field2 || ',' || field3 and capture the output of that to a file, but that's an uglier hack than the temptable trick. -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com 512-569-9461