Excluding tables from pg_restore

Started by Carlos Olivaalmost 23 years ago2 messagesgeneral
Jump to latest
#1Carlos Oliva
carlos@pbsinet.com

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

#2Nigel J. Andrews
nandrews@investsystems.co.uk
In reply to: Carlos Oliva (#1)
Re: Excluding tables from pg_restore

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