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

From: Vibhor Kumar <vibhor(dot)kumar(at)enterprisedb(dot)com>
To: <david(dot)sahagian(at)emc(dot)com> <david(dot)sahagian(at)emc(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: COPY TO '|gzip > /my/cool/file.gz'
Date: 2011-07-20 18:53:53
Message-ID: 0CAB7944-B259-4716-AE41-3A59205C907D@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jul 20, 2011, at 11:29 PM, <david(dot)sahagian(at)emc(dot)com> <david(dot)sahagian(at)emc(dot)com> wrote:

> From May 31, 2006; 12:03pm . . .
>
> "It struck me that we are missing a feature that's fairly common in Unix programs.
> Perhaps COPY ought to have the ability to pipe its output to a shell command,
> or read input from a shell command. "
> Maybe something like:
> COPY mytable TO '| gzip >/home/tgl/mytable.dump.gz';
>
> Is such a feature (ie being able to tell postgres to write a compressed file via COPY TO) being worked on ?
>

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

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
Blog: http://vibhork.blogspot.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Haas 2011-07-20 18:55:34 Re: A few user-level questions on Streaming Replication and pg_upgrade
Previous Message Bruce Momjian 2011-07-20 18:53:07 Re: A few user-level questions on Streaming Replication and pg_upgrade