Re: Restore 1 Table from pg_dumpall? - Mailing list pgsql-general

From Ondrej Ivanič
Subject Re: Restore 1 Table from pg_dumpall?
Date
Msg-id CAM6mieJ2ge0=wOU+MYaJ7owd9kxgtWZgYTMtVutXX074FCeMAg@mail.gmail.com
Whole thread Raw
In response to Restore 1 Table from pg_dumpall?  (Rich Shepard <rshepard@appl-ecosys.com>)
List pgsql-general
Hi,

On 23 January 2013 04:57, Rich Shepard <rshepard@appl-ecosys.com> wrote:
>   Is there a way I can extract a single table's schema and data from the
> full backup? If so, I can then drop the fubar'd table and do it correctly
> this time.

You should grep for:
- CREATE TABLE
- COPY

statements and then note line numbers (fgrep -n). Finally, used `sed`
to get the right part(s) of a file (schema + data):
sed -n 'startline,endlinep' dump.sql > out.sql  (ie. sed -n '10,1000p')

--
Ondrej


pgsql-general by date:

Previous
From: Rich Shepard
Date:
Subject: Re: seeking SQL book recommendation
Next
From: Adrian Klaver
Date:
Subject: Re: Postfresql 8.4 Problem