Thread: Restore single table from pg_dumpall.

Restore single table from pg_dumpall.

From
"Jim Stalewski"
Date:

Greetings,

I have been asked by a programmer to restore a single table from a PG_DUMPALL backup.

Is this possible, and if so, would anyone be able to tell me please, what PSQL options and switches are required?  Running PostgreSQL 8.1.3.

Thanks in advance,

Jim.

 

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender and delete it. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. No employee or agent is authorized to conclude any binding agreement on behalf of Visa Lighting with another party by email without express written confirmation by an authorized representative of the Company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

Re: Restore single table from pg_dumpall.

From
"Andrej Ricnik-Bay"
Date:
On 1/23/07, Jim Stalewski <JStalewski@visalighting.com> wrote:

> I have been asked by a programmer to restore a single table from a
> PG_DUMPALL backup.
>
> Is this possible, and if so, would anyone be able to tell me please, what
> PSQL options and switches are required?  Running PostgreSQL 8.1.3.
Not sure whether this is an option for you, but I'd make a copy,
fire up vim and strip all I don't want out of the copy.

If I wanted to be able to restore individual databases I'd dump
them individually.


Cheers,
Andrej

Re: Restore single table from pg_dumpall.

From
Alan Hodgson
Date:
> On 1/23/07, Jim Stalewski <JStalewski@visalighting.com> wrote:
> > I have been asked by a programmer to restore a single table from a
> > PG_DUMPALL backup.
> >
> > Is this possible, and if so, would anyone be able to tell me please,
> > what PSQL options and switches are required?  Running PostgreSQL 8.1.3.

This is a lot simpler with a tar or custom format backup from pg_dump.
Using that, you could dump the ToC and modify it to select the table you
want to restore.

With a pg_dumpall backup you might just be better off restoring the whole
thing into an empty cluster, and then dump the one table only from there.
Unless it's small enough to load into a text editor, of course.

--
"A government that robs Peter to pay Paul can always depend upon the support
of Paul." - George Bernard Shaw


Re: [SPAM] Restore single table from pg_dumpall.

From
"Duncan Garland"
Date:
Hi,
 
pg_restore can restore a single table provided that the appropriate switch was used when creating the dump with pg_dumpall.
 
If the dump is in plain text then you need to strip out the surplus data and feed the rest to psql. If the file is too big for vi, try a stream editor such as sed or a simple perl script.
 
Regards
 
Duncan
-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Jim Stalewski
Sent: 22 January 2007 23:06
To: pgsql-novice@postgresql.org
Subject: [SPAM] [NOVICE] Restore single table from pg_dumpall.

Greetings,

I have been asked by a programmer to restore a single table from a PG_DUMPALL backup.

Is this possible, and if so, would anyone be able to tell me please, what PSQL options and switches are required?  Running PostgreSQL 8.1.3.

Thanks in advance,

Jim.

 

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender and delete it. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. No employee or agent is authorized to conclude any binding agreement on behalf of Visa Lighting with another party by email without express written confirmation by an authorized representative of the Company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

Re: [SPAM] Restore single table from pg_dumpall.

From
Jim Nasby
Date:
On Jan 23, 2007, at 5:13 AM, Duncan Garland wrote:
> If the dump is in plain text then you need to strip out the surplus
> data and feed the rest to psql. If the file is too big for vi, try
> a stream editor such as sed or a simple perl script.

I find that using less to get line numbers and then using a
combination of head and tail works well. Almost guaranteed to be a
whole lot faster than loading a large file into vi.
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)