On Tue, Sep 13, 2011 at 2:55 PM, Joshua D. Drake
<jd@commandprompt.com> wrote:
On 09/13/2011 11:51 AM, Michael Nolan wrote:
The ability to restore a table from a backup file to a different
table
name in the same database and schema.
This can be done but agreed it is not intuitive.
Can you elaborate on tha a bit, please? The only way I've been able to
do it is to edit the dump file to change the table name. That's not
very practical with a several gigabyte dump file, even less so with one
that is much larger. If this capability already exists, is it documented?
You use the -Fc method, extract the TOC and edit just the TOC (so you don't have to edit a multi-gig file)
That is, at best, a bit obscure. I've wondered at times if the -f tar option would have any benefits here, though it appears to have significant downsides.
A downside of either method may be that I can't predict in advance when I will want to do a restore of a single table from a backup file,
so I'd have to always use that method of generating the file.
I did propose an extension to pg_restore a couple of months ago to add an option to re-name a table as it is restored, but that seemed to have generated no interest.
Maybe an external tool that reads a pg_dump file looking for a specific table and writes that portion of the dump file to a separate file, changing the table name would be easier? It'd probably have to handle most of or all of the different pg_dump formats, but that doesn't sound like an unachievable goal.
--
Mike Nolan