Re: fine tuned database dump/reload?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: fine tuned database dump/reload?
Дата
Msg-id 434C09A1.3070103@archonet.com
обсуждение исходный текст
Ответ на Re: fine tuned database dump/reload?  (Dan Armbrust <daniel.armbrust.list@gmail.com>)
Список pgsql-general
Dan Armbrust wrote:
>
> Is there a better way to do this?  Is there a flag I could specify for
> psql that would cause it to output INSERT or COPY statements as a result
> of a query - select * from foo where terminologyId=foo?  Then I could
> just have 15 select statements batched up in a file, and pipe the output
> into a new file.

It's easy enough to get psql to output tab-separated columns to a file
from its query (see the various backslash formatting commands and \o).
Spit out the 15 different files you want to /tmp, then use a script with
COPY ... FROM /tmp/file1 etc.

If you use COPY the files need to be readable by the backend process,
otherwise look into \copy in a psql script.

If it gets much more complicated, I knock up a short Perl script. Others
probably prefer Python or Ruby.
--
   Richard Huxton
   Archonet Ltd

В списке pgsql-general по дате отправления:

Предыдущее
От: Tony Caduto
Дата:
Сообщение: Re: Considering an upgrade...
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Considering an upgrade...