pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedRestore
6+ messages / 5 participants
[nested] [flat]
* Restore
@ 2003-10-17 02:42 lei_xiong@vtech.com
0 siblings, 0 replies; 6+ messages in thread
From: lei_xiong@vtech.com @ 2003-10-17 02:42 UTC (permalink / raw)
To: pgsql-admin
Dear Pgsql-admin:
We are now using pgsql(ver 7.0), the disk of our server is bad
yestoday. I find that the all database file is ok and I have no make any
backup. Can you help me to restore?
Thanks and wait for you reply urgent,
Lei Xiong
^ permalink raw reply [nested|flat] 6+ messages in thread
* restore
@ 2010-10-05 18:08 Dinesh Bhandary <dbhandary@iii.com>
0 siblings, 2 replies; 6+ messages in thread
From: Dinesh Bhandary @ 2010-10-05 18:08 UTC (permalink / raw)
To: pgsql-admin
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.
Thanks.
Dinesh
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: restore
@ 2010-10-05 18:15 Kevin Grittner <Kevin.Grittner@wicourts.gov>
parent: Dinesh Bhandary <dbhandary@iii.com>
1 sibling, 1 reply; 6+ messages in thread
From: Kevin Grittner @ 2010-10-05 18:15 UTC (permalink / raw)
To: dbhandary@iii.com; pgsql-admin
Dinesh Bhandary <dbhandary@iii.com> wrote:
> Is there an easy way to restore to a new table where the column
> name have been changed but data remains the same?
Restore to the old name and then rename the column?
Access the backup file and change the COPY statement to the new
column name?
If you can redo the dump, you don't mind the load running a little
slower, and the column order is the same -- dump with the --inserts
switch?
-Kevin
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: restore
@ 2010-10-05 18:19 Scott Whitney <scott@journyx.com>
0 siblings, 0 replies; 6+ messages in thread
From: Scott Whitney @ 2010-10-05 18:19 UTC (permalink / raw)
To: dbhandary@iii.com; +Cc: 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:
Assuming:
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.
Thanks.
Dinesh
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: restore
@ 2010-10-05 18:32 Dinesh Bhandary <dbhandary@iii.com>
parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 0 replies; 6+ messages in thread
From: Dinesh Bhandary @ 2010-10-05 18:32 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: pgsql-admin
Awesome, this will work. It won't retain the column name in insert
into statement. I was not sure if this will work with postgres 8.2.5 but
it does.
Thanks.
Dinesh
On 10/5/2010 11:15 AM, Kevin Grittner wrote:
> Dinesh Bhandary<dbhandary@iii.com> wrote:
>
>> Is there an easy way to restore to a new table where the column
>> name have been changed but data remains the same?
>
> Restore to the old name and then rename the column?
>
> Access the backup file and change the COPY statement to the new
> column name?
>
> If you can redo the dump, you don't mind the load running a little
> slower, and the column order is the same -- dump with the --inserts
> switch?
>
> -Kevin
>
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: restore
@ 2010-10-05 20:50 Craig James <craig_james@emolecules.com>
parent: Dinesh Bhandary <dbhandary@iii.com>
1 sibling, 0 replies; 6+ messages in thread
From: Craig James @ 2010-10-05 20:50 UTC (permalink / raw)
To: pgsql-admin
On 10/5/10 11:08 AM, Dinesh Bhandary wrote:
> 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.
If your data file is plain text with a COPY or INSERT commands, do this using psql:
begin;
alter table1 rename col2 to col1;
\i datafile.sql
alter table1 rename col1 to col2;
commit;
Craig
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2010-10-05 20:50 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-17 02:42 Restore lei_xiong@vtech.com
2010-10-05 18:08 restore Dinesh Bhandary <dbhandary@iii.com>
2010-10-05 18:15 ` Re: restore Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-10-05 18:32 ` Re: restore Dinesh Bhandary <dbhandary@iii.com>
2010-10-05 20:50 ` Re: restore Craig James <craig_james@emolecules.com>
2010-10-05 18:19 Re: restore Scott Whitney <scott@journyx.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox