Re: Defining the same relation in another database

Поиск
Список
Период
Сортировка
От Guido Barosio
Тема Re: Defining the same relation in another database
Дата
Msg-id f7f6b4c70604190155p1690e229jbebb9247943edae7@mail.gmail.com
обсуждение исходный текст
Ответ на Defining the same relation in another database  (Michael Talbot-Wilson <mtw@view.net.au>)
Ответы Re: Defining the same relation in another database
Список 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 по дате отправления:

Предыдущее
От: "Shoaib Mir"
Дата:
Сообщение: Re: Defining the same relation in another database
Следующее
От: "Robert Landsmeer"
Дата:
Сообщение: Re: Find all foreign keys and dropping them from a script.