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 91DF4D76B8 for ; Tue, 11 Oct 2005 20:02:18 -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 45982-02 for ; Tue, 11 Oct 2005 23:02:13 +0000 (GMT) Received: from fetter.org (dsl092-188-065.sfo1.dsl.speakeasy.net [66.92.188.65]) by svr1.postgresql.org (Postfix) with ESMTP id 41212D7260 for ; Tue, 11 Oct 2005 20:02:15 -0300 (ADT) Received: from fetter.org (localhost.localdomain [127.0.0.1]) by fetter.org (8.13.4/8.12.10) with ESMTP id j9BN2HUi016996 for ; Tue, 11 Oct 2005 16:02:17 -0700 Received: (from shackle@localhost) by fetter.org (8.13.4/8.13.4/Submit) id j9BN2Hwm016995 for pgsql-docs@postgresql.org; Tue, 11 Oct 2005 16:02:17 -0700 Date: Tue, 11 Oct 2005 16:02:17 -0700 From: David Fetter To: PostgreSQL Docs Subject: COPY example for partial tables Message-ID: <20051011230217.GD6239@fetter.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.067 required=5 tests=[AWL=0.017, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/24 X-Sequence-Number: 3269 --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. Cheers, D -- David Fetter david@fetter.org http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote! --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="copy_example.diff" Index: doc/src/sgml/ref/copy.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v retrieving revision 1.67 diff -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 11 Oct 2005 23:00:40 -0000 *************** *** 709,714 **** --- 709,730 ---- + To copy just the countries whose names start with 'A' into a file + using a temporary table which goes away at the end of the + transaction. This workaround will probably not be + needed for PostgreSQL 8.2 and + later. + + 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; + VACUUM; + + + + Here is a sample of data suitable for copying into a table from STDIN: --2oS5YaxWCcQjTEyO--