Re: how to create dump of selected rows from a table - Mailing list pgsql-general

From Adrian Klaver
Subject Re: how to create dump of selected rows from a table
Date
Msg-id 56742367.6020003@aklaver.com
Whole thread Raw
In response to how to create dump of selected rows from a table  (anj patnaik <patna73@gmail.com>)
Responses Re: how to create dump of selected rows from a table  (Melvin Davidson <melvin6925@gmail.com>)
List pgsql-general
On 12/17/2015 09:28 AM, anj patnaik wrote:
> Currently, I am running pg_dump on an entire table of a database by doing:
>
>   PGPASSWORD=$PGPASSWORDB /opt/data/PostgreSQL/9.4/bin/pg_dump -t
> RECORDER -Fc $i -U pguser -Z0 | xz -9 > "$backup_dir/$i-$timeslot-database"
>
> However, this table has a lot of rows.
>
> Is there a way I could do pg_dump on a subset of rows that match a
> criteria say via a sql statement?

Yes it is called COPY:):

http://www.postgresql.org/docs/9.4/interactive/sql-copy.html

or its psql equivalent \copy:

http://www.postgresql.org/docs/9.4/interactive/app-psql.html

>
> Does anyone have any snippets on how to do that?
>
> Thank you


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Check old and new tuple in row-level policy?
Next
From: Melvin Davidson
Date:
Subject: Re: how to create dump of selected rows from a table