Thread: Excluding tables from pg_restore

Excluding tables from pg_restore

From
Carlos
Date:

Hi forum,

How can I exclude a few tables from a pg_dump and a pg_restore?  I have a pg_dump of a database with several hundred tables and I want to restore most of these tables into another database hence I want to exclude a couple of the tables from the restore.  In the man pages, I found the -t option for pg_restore but I would have to name several hundreds tables to use this.

Thanks in advance for your response

Re: Excluding tables from pg_restore

From
"Nigel J. Andrews"
Date:
On Mon, 16 Jun 2003, Carlos wrote:

> Hi forum,
>
> How can I exclude a few tables from a pg_dump and a pg_restore?  I have a
> pg_dump of a database with several hundred tables and I want to restore most
> of these tables into another database hence I want to exclude a couple of
> the tables from the restore.  In the man pages, I found the -t option for
> pg_restore but I would have to name several hundreds tables to use this.
>
> Thanks in advance for your response
>

Well, you could write a little wrapper script that took a list of tables to
exclude, listed the tables in an archive, filtered out the ones given to your
wrapper script and  ran pg_restore with what was left.

Of course you'll have to take care not to exceed command line lengths which
means you'd have to be prepared for multiple invocations of pg_restore to load
all the table, or use a langauge you can exec pg_restore directly.


--
Nigel J. Andrews