Re: Combining \i and \copy in psql

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Combining \i and \copy in psql
Дата
Msg-id CAKFQuwbRDM1e2+m4MLdYr6wOo1KU8y4CVbbmO5G9A56woFzrHQ@mail.gmail.com
обсуждение исходный текст
Ответ на Combining \i and \copy in psql  ("Rhys A.D. Stewart" <rhys.stewart@gmail.com>)
Список pgsql-general
On Tue, May 15, 2018 at 8:30 AM, Rhys A.D. Stewart <rhys.stewart@gmail.com> 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.

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

Предыдущее
От: "Rhys A.D. Stewart"
Дата:
Сообщение: Combining \i and \copy in psql
Следующее
От: raf@raf.org
Дата:
Сообщение: Re: Control PhoneNumber Via SQL