public inbox for [email protected]
help / color / mirror / Atom feedFrom: David Fetter <[email protected]>
To: PostgreSQL Docs <[email protected]>
Subject: COPY example for partial tables
Date: Tue, 11 Oct 2005 16:02:17 -0700
Message-ID: <[email protected]> (raw)
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 [email protected] http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778
Remember to vote!
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 ----
</para>
<para>
+ 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. <note><para>This workaround will probably not be
+ needed for <productname>PostgreSQL</productname> 8.2 and
+ later.</para></note>
+ <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;
+ VACUUM;
+ </programlisting>
+ </para>
+
+ <para>
Here is a sample of data suitable for copying into a table from
<literal>STDIN</literal>:
<programlisting>
Attachments:
[text/plain] copy_example.diff (1.1K, 2-copy_example.diff)
download | inline 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 ----
</para>
<para>
+ 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. <note><para>This workaround will probably not be
+ needed for <productname>PostgreSQL</productname> 8.2 and
+ later.</para></note>
+ <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;
+ VACUUM;
+ </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]
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