public inbox for [email protected]  
help / color / mirror / Atom feed
From: Bruce Momjian <[email protected]>
To: David Fetter <[email protected]>
Cc: PostgreSQL Docs <[email protected]>
Subject: Re: COPY example for partial tables
Date: Wed, 12 Oct 2005 10:55:17 -0400 (EDT)
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

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
  [email protected]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

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 ----
    </para>
  
    <para>
+    To copy into a file just the countries whose names start with 'A'
+    using a temporary table which is automatically deleted:
+   </para>
+ <programlisting>
+ 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;
+ </programlisting>
+   </para>
+ 
+   <para>
     Here is a sample of data suitable for copying into a table from
     <literal>STDIN</literal>:
  <programlisting>


Attachments:

  [text/plain] /rtmp/diff (924B, 2-%2Frtmp%2Fdiff)
  download | inline:
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 ----
    </para>
  
    <para>
+    To copy into a file just the countries whose names start with 'A'
+    using a temporary table which is automatically deleted:
+   </para>
+ <programlisting>
+ 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;
+ </programlisting>
+   </para>
+ 
+   <para>
     Here is a sample of data suitable for copying into a table from
     <literal>STDIN</literal>:
  <programlisting>

view thread (9+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: COPY example for partial tables
  In-Reply-To: <[email protected]>

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

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