Re: Restoring a table with a different name

From: Adam Ruth <aruth(at)intercation(dot)com>
To: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
Cc: jimw(at)kelcomaine(dot)com, pgsql-general(at)postgresql(dot)org (pgsql general list)
Subject: Re: Restoring a table with a different name
Date: 2004-02-28 02:06:58
Message-ID: CA4E1E1E-6992-11D8-80AC-000A959D1424@intercation.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You may be better off with renaming the existing table, importing, then
doing more renaming to get everything in the right place:

alter table memmast rename to memmast_temp;

<import table>

alter table memmast rename to wk_memmast;

alter table memmast_temp rename to memmast;

That way you don't need to muck with the dump file.

On Feb 27, 2004, at 7:03 PM, Mike Nolan wrote:

>>> If I edit the dump file with 'sed' to change the table name, I get
>>> 'invalid command \N' errors trying to reload it.
>>
>> What sed syntax are you using?
>
> Here's the command line I used:
>
> sed -e 's/memmast/wk_memmast/' memmast.dmp > wk_memmast.dmp
>
> I see two potential problems here, and it took both of them to bite me.
>
> One is that I'm not changing all occurrences of 'memmast' to
> 'wk_memmast'.
> The other is that the string 'memmast' can and does occur within the
> name of another column, so the name of that column was edited by sed
> in the CREATE TABLE statement but not in the LOAD command.
>
> Changing the command line to:
>
> sed -e 's/ memmast / wk_memmast /' memmast.dmp > wk_memmast.dmp
>
> works, and without changing that column name.
>
> I think, however, that I may need to go with the other method (copying
> the table and dumping/restoring the copy), because the restore runs
> into
> name conflicts with several indexes and there is a trigger procedure
> on that table.
> --
> Mike Nolan
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2004-02-28 02:09:38 Re: efficient storing of urls
Previous Message Mike Nolan 2004-02-28 02:03:26 Re: Restoring a table with a different name