Обсуждение: Suggested enhancement to pg_restore

Поиск
Список
Период
Сортировка

Suggested enhancement to pg_restore

От
Michael Nolan
Дата:
I suggest adding the following parameter to pg_restore:

--rename-table=XXXX

When used in conjunction with the --data-only, --schema and -t options (all three of which would be necessary),
it would allow restoring a table (without indexes) to a different table name (which would need to already exist
and match the structure of the table which is being restored, of course.)

This would give PostgreSQL users the ability to reload a table from a dump file to a separate table name in the
same database and schema. 

In other words, this command:

pg_restore --data-only --schema=abc -t xyz --rename-table=xyz_copy

would restore a copy of table xyz into the existing (and presumably empty) table xyz_copy, leaving table xyz untouched.
--
Mike Nolan
nolan@tssi.com

Re: Suggested enhancement to pg_restore

От
Chris Travers
Дата:
On Tue, Jul 26, 2011 at 3:48 PM, Michael Nolan <htfoot@gmail.com> wrote:
> I suggest adding the following parameter to pg_restore:
>
> --rename-table=XXXX
>
> When used in conjunction with the --data-only, --schema and -t options (all
> three of which would be necessary),
> it would allow restoring a table (without indexes) to a different table name
> (which would need to already exist
> and match the structure of the table which is being restored, of course.)

Does pg_restore allow you to specify a set of tables the same way
pg_dump does, i.e. by -t table1 -t table2?

If so how would this feature play along?

Best Wishes,
Chris Travers

Re: Suggested enhancement to pg_restore

От
Michael Nolan
Дата:


On Tue, Jul 26, 2011 at 6:10 PM, Chris Travers <chris.travers@gmail.com> wrote:
On Tue, Jul 26, 2011 at 3:48 PM, Michael Nolan <htfoot@gmail.com> wrote:
> I suggest adding the following parameter to pg_restore:
>
> --rename-table=XXXX
>
> When used in conjunction with the --data-only, --schema and -t options (all
> three of which would be necessary),
> it would allow restoring a table (without indexes) to a different table name
> (which would need to already exist
> and match the structure of the table which is being restored, of course.)

Does pg_restore allow you to specify a set of tables the same way
pg_dump does, i.e. by -t table1 -t table2?

If so how would this feature play along?

Not sure, the man page for pg_restore seems to imply that -t can be used to restore just ONE table, 
though it also seems to say that pg_restore can be used to affect the order in which the tables are restored.

If it can handle multiple -t entries, presumably they must all be in the same schema, otherwise things
could get really confused if the same table name exists in more than one schema.

If multiple -t entries are supported, I guess we would have two options.

1.  Only allow one table to be restored using the --rename-table parameter at a time. 

2.  Require that the command have matching pairs of -t and --rename-table entries to make sure that the tables
are restored to the intended new names. 

I don't have a major preference between these, though I suspect #1 would be easier to implement.
--
Mike Nolan
nolan@tssi.com