Re: Defining the same relation in another database - Mailing list pgsql-novice

From Guido Barosio
Subject Re: Defining the same relation in another database
Date
Msg-id f7f6b4c70604190155p1690e229jbebb9247943edae7@mail.gmail.com
Whole thread Raw
In response to Defining the same relation in another database  (Michael Talbot-Wilson <mtw@view.net.au>)
Responses Re: Defining the same relation in another database  (Michael Talbot-Wilson <mtw@view.net.au>)
List pgsql-novice
Shortly:

You just need to user pg_dump and psql. You may use them alltogether
in one piped sentence, or in two different sentences

a)

To run pg_dump, get the schema, no data,  a single table, and redirect
STDOUT to the psql command, which should take the imput and follow the
SQL instructions.

pg_dump -s -t table databaseA | psql databaseB

b)

To run pg_dump, get the schema, no data, a single table, and redirect
STDOUT to a file.
You may pickup that file later with psql -f.

1. pg_dump -s -t table databaseA > table_schema.sql
2. psql -f table_schema.sql databaseB

Good luck,
Guido

On 4/19/06, Michael Talbot-Wilson <mtw@view.net.au> wrote:
> How do you do this?  I guess it may require heroic methods such as the
> editing of dumps.  Or it is easy?
>
> I'd like to do this because the \d is complicated.  I've prototyped
> this thing in a temp database and now I'd like to do it for real.  I'd
> rather not copy it down on paper and do it all again.
>
> It is okay to move the relation and its data, but I really just want
> to recreate it in another database.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>


--
Guido Barosio
-----------------------
http://www.globant.com
guido.barosio@globant.com

pgsql-novice by date:

Previous
From: "Shoaib Mir"
Date:
Subject: Re: Defining the same relation in another database
Next
From: "Robert Landsmeer"
Date:
Subject: Re: Find all foreign keys and dropping them from a script.