Search Postgresql Archives

Re: fine tuned database dump/reload?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux