Re: pg_dump with select command - Mailing list pgsql-general

From Ondrej Ivanič
Subject Re: pg_dump with select command
Date
Msg-id CAM6mie+8hZPyaXCGgHTwS3=ECzwkLyLn99R4LEtkXgUG7+yNnA@mail.gmail.com
Whole thread Raw
In response to pg_dump with select command  (Adarsh Sharma <adarsh.sharma@orkash.com>)
List pgsql-general
Hi,


On 12 September 2011 15:03, Adarsh Sharma <adarsh.sharma@orkash.com> wrote:
> Today I need some part ( subset ) of some tables to another database to a
> remote server.
> I need to take backup of  tables after satisfying a select query.
>
> Is there any option to specify query in pg_dump command.I researched in the
> manual but not able to find that.
> Please let me know if it is possible as we can can specify in mysqldump
> command.

No, pg_dump can dump full tables only. You can use psql:

psql -h <host1> ... -c 'copy (select ... from <tablename> where ...)
to stdout' | psql -h <host2> ...  -c 'copy <tablename> from stdin'

(where '...' are other psql's options like user, db, ...)

--
Ondrej Ivanic
(ondrej.ivanic@gmail.com)

pgsql-general by date:

Previous
From: "Rogel Nocedo"
Date:
Subject: servoy-postgresql plugin
Next
From: Simon Riggs
Date:
Subject: Re: servoy-postgresql plugin