Skip site navigation (1) Skip section navigation (2)

Re: restoring a .dmp file to another table name

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
Cc: pgsql general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: restoring a .dmp file to another table name
Date: 2004-08-23 06:43:53
Message-ID: 1093243433.1520.18.camel@Andrea.peacock.de (view raw or flat)
Thread:
Lists: pgsql-general
Hi,

Am Mo, den 23.08.2004 schrieb Mike Nolan um 6:15:
> I've probably asked this question before, but what do people do when they
> need to restore a table that has been dumped but as a different table
> name?  That doesn't appear to be an option in pg_restore.  (Is that just
> a front end to psql?)
> 
> I need both the old table and the live one in the same database so
> that I can compare a set of values to see what changed, and I don't have
> a spare system to do it on at the moment, nor can I rename the live file
> since it is in use most of the day.  
> 
> This is a fairly large table (2.8M rows, 500MB dump file) and I think 
> it may have some data in it that would get messed up if I were to try to 
> extract the DDL leading up to the COPY statement using head and tail
> statements to change the table name.

Just use pg_restore -t tablename (and the other options according to
your pg_dump) and write the results in a file. Use an editor to change
tablename to your new tablename in the result. If you are absolute
sure your tablename does not appear as data payload in the table,
you can use sed like this:

pg_restore -t tablename | sed -e "s/tablename/newtablename/" | psql

HTH
Tino Wildenhain


In response to

pgsql-general by date

Next:From: Thomas HallgrenDate: 2004-08-23 06:46:42
Subject: ANN: PL/Java now supports both PostgreSQL 8.0 and 7.4
Previous:From: Mike NolanDate: 2004-08-23 04:15:38
Subject: restoring a .dmp file to another table name

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group