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

Re: restore

From: Scott Whitney <scott(at)journyx(dot)com>
To: dbhandary(at)iii(dot)com
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: restore
Date: 2010-10-05 18:19:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
There are a couple of ways. Assuming that it's the same database, and it's up and running, you could do this: 

table foo (col1 text, col2 int); 
table bar (col2 text, col3 int); 

insert into bar (select * from foo); 

would stick everything from foo.col1 and foo.col2 into bar.col2 and bar.col3 respectively. 

Using pg_dump, you could dump just the table: 
pg_dump -t foo mydatabase 

and edit the CREATE TABLE statement. 

Hi All, 

Is there an easy way to restore to a new table where the column name 
have been changed but data remains the same? 
For example I am trying to restore from existing system, table1(col1) 
to table1(col2) and it is erroring out on the new column name even 
though it is a data only restore. I was just wondering if there is a 
quick way to bypass this. Let me know. 



Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org) 
To make changes to your subscription: 

pgsql-admin by date

Next:From: Dinesh BhandaryDate: 2010-10-05 18:32:29
Subject: Re: restore
Previous:From: Kevin GrittnerDate: 2010-10-05 18:15:32
Subject: Re: restore

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