Search Postgresql Archives

Re: Combining \i and \copy in psql

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

 



On Tue, May 15, 2018 at 8:30 AM, Rhys A.D. Stewart <rhys.stewart@xxxxxxxxx> wrote:
Greetings,

I have a query in a .sql file and I'd like to use \i to execute it and
\copy to save it to a csv file. Is there any way to combine the two?

Something along the lines of:

\copy \i myquery.sql to 'output.csv'

​Maybe try something like:

\o output.csv
COPY (
\i myquery.sql
) TO stdout;
\o
You'll need to use COPY if you want to mix in \i with a query that would otherwise operate as a standard select query.

David J.


[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