X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D4557D7E95 for ; Wed, 12 Oct 2005 11:55:17 -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 36847-02 for ; Wed, 12 Oct 2005 14:55:12 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id 800D9D7E93 for ; Wed, 12 Oct 2005 11:55:14 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j9CEtHt10423; Wed, 12 Oct 2005 10:55:17 -0400 (EDT) From: Bruce Momjian Message-Id: <200510121455.j9CEtHt10423@candle.pha.pa.us> Subject: Re: COPY example for partial tables In-Reply-To: <20051011230217.GD6239@fetter.org> To: David Fetter Date: Wed, 12 Oct 2005 10:55:17 -0400 (EDT) Cc: PostgreSQL Docs X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM1129128917-10063-0_ Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 required=5 tests=[AWL=0.013] X-Spam-Level: X-Archive-Number: 200510/31 X-Sequence-Number: 3276 --ELM1129128917-10063-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII David Fetter wrote: > Folks, > > Please find enclosed a patch (should work for 7.3 and up) that > illustrates a workaround for using COPY on parts of tables using > temporary tables. It's helped me, and it seems popular via a very > brief and un-scientific poll. I have attached and applied a modified version of this patch. I removed the VACUUM (because this is just an example and does not need to be a complete solution, e.g. pg_class bloat), and removed the 8.2 mention because it seemed unnecessary. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 --ELM1129128917-10063-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain Content-Disposition: inline; filename="/rtmp/diff" Index: doc/src/sgml/ref/copy.sgml =================================================================== RCS file: /cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v retrieving revision 1.67 diff -c -c -r1.67 copy.sgml *** doc/src/sgml/ref/copy.sgml 5 Sep 2005 14:44:05 -0000 1.67 --- doc/src/sgml/ref/copy.sgml 12 Oct 2005 14:53:17 -0000 *************** *** 709,714 **** --- 709,727 ---- + To copy into a file just the countries whose names start with 'A' + using a temporary table which is automatically deleted: + + + BEGIN; + CREATE TEMP TABLE a_list_COUNTRIES AS + SELECT * FROM country WHERE country_name LIKE 'A%'; + COPY a_list_countries TO '/usr1/proj/bray/sql/a_list_countries.copy'; + ROLLBACK; + + + + Here is a sample of data suitable for copying into a table from STDIN: --ELM1129128917-10063-0_--