Re: restore single table

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Kevin Duffy *EXTERN*" <KD(at)wrinvestments(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: restore single table
Date: 2009-02-24 12:07:15
Message-ID: D960CB61B694CF459DCFB4B0128514C2031AB0A7@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kevin Duffy wrote:
> I need guidance on how move some changes that I have made to
> my production database.
>
> On my development database I made changes to a table called
> DEPT. I added a column, added
>
> a couple of records and did some general data cleanup
>
>
>
> What I did not do was change any of the keys on existing
> records. The primary key of DEPT is a
>
> foreign key in several other tables.
>
>
>
> Here is my question: Can I do a table restore on to the
> production database and expect these
>
> changes to be moved over? Will the restore handle, via some
> magic, "suspend" the foreign key
>
> constraints and allow the new table structure to be created
> and then populated with new data.
>
>
>
> I have not changed the keys of existing records so that
> existing relationships should be restored.

A few thoughts:

Maybe you do not need to delete and recreate the table.
An ALTER TABLE statement can, for example, add a column to
an existing table.
That way you could leave the foreign key constraints in place
while you do the update.

If you cannot avoid dropping and recreating the table, you
could proceed like this: drop all foreign key constraints
to your table, recreate it and add the constraints again.

You should write an SQL script that does the necessary changes
and test it beforehand.

Lock out all database users while you perform substantial changes
to the database.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Abdul Rahman 2009-02-24 12:46:30 Oracle Functions to PostgreSQL
Previous Message 野村 2009-02-24 10:55:29 Re: javascript and postgres