Re: copying between Postgres databases

From: Andrew Sullivan <andrew(at)libertyrms(dot)info>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: copying between Postgres databases
Date: 2003-03-17 21:45:46
Message-ID: 20030317164546.Y3789@mail.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Mar 17, 2003 at 10:21:29AM +0100, javier garcia - CEBAS wrote:
> Hi;
> I've got two questions:
>
> 1) What is the best way to copy a Postgres table in one database into another
> Postgres database? Is it possible to copy the structure and the data at the
> same time?

pg_dump -t [tablename] -c -h [host1] database | psql -h [host2] database2

> 2) Is there a way to do a short of pg_dump and to use the resulting file as
> input to another database, but preserving existing tables in this latter?

The above will overwrite [tablename] in the target if it exists. Use
it without -c if you want to preserve what's there, but be prepared
for not-quite-what-you-expected results.

A

--
----
Andrew Sullivan 204-4141 Yonge Street
Liberty RMS Toronto, Ontario Canada
<andrew(at)libertyrms(dot)info> M2P 2A8
+1 416 646 3304 x110

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joseph Shraibman 2003-03-17 22:10:16 Re: ERROR: out of free buffers: time to abort!
Previous Message Andrew Sullivan 2003-03-17 21:27:47 Re: The folding of unquoted names to lower case in PostgreSQL