Re: COPY TO '|gzip > /my/cool/file.gz'

From: Willy-Bas Loos <willybas(at)gmail(dot)com>
To: Vibhor Kumar <vibhor(dot)kumar(at)enterprisedb(dot)com>
Cc: "<david(dot)sahagian(at)emc(dot)com>" <david(dot)sahagian(at)emc(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: COPY TO '|gzip > /my/cool/file.gz'
Date: 2011-07-22 10:52:09
Message-ID: CAHnozTgDmYethXH57uKgmMR2juK8mHxTO3cg0uryvDQC_T7MEw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jul 20, 2011 at 8:53 PM, Vibhor Kumar
<vibhor(dot)kumar(at)enterprisedb(dot)com> wrote:
> You can use STDOUT to pipe output to a shell command and STDIN to read input from shell command.
> Something like given below:
> psql -c "COPY mytable to STDOUT"|gzip >/home/tgl/mytable.dump.gz
>
> cat filename|psql -c "COPY mytable from STDIN;"
>
> OR psql -c "COPY mytable from STDIN;" < filename

nice one, that works great!
(zcat instead of cat, though)

--
"Patriotism is the conviction that your country is superior to all
others because you were born in it." -- George Bernard Shaw

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2011-07-22 11:24:08 Re: Tracing in Postgres
Previous Message Achilleas Mantzios 2011-07-22 10:25:21 Re: Choosing primary key type: 64 or 52 bit primary keys?