Re: Restoring selected records from backup file

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Piyush Lenka <lenka(dot)piyush(at)gmail(dot)com>
Subject: Re: Restoring selected records from backup file
Date: 2012-03-02 23:21:13
Message-ID: 201203021521.13487.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday, March 02, 2012 2:20:14 am Piyush Lenka wrote:
> hi,
>
> 1. How can we restore selected records from a plain text backup
> (backup.sql).

The only way I know is to use some text processing tool to walk through and pull
out the records.

> 2. Is it possible using psql. If yes how

I assume you mean the psql client program. There is no way to get it to read a
backup file and pull data, as far as I know.

You can use the \copy command to pull out selected records from a table and dump
them to a disk file. See here for more info:
http://www.postgresql.org/docs/9.0/interactive/app-psql.html

You could also do a CREATE TABLE AS to create a table with the records you are
interested and then do pg_dump -t to get that information.

http://www.postgresql.org/docs/9.0/interactive/sql-createtableas.html

> Please Help
>
> Thanks & Regards
> Piyush

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Prause 2012-03-02 23:30:00 Re: role missing in dump
Previous Message Adrian Klaver 2012-03-02 23:14:18 Re: role missing in dump