Re: variable filename for psql \copy

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: variable filename for psql \copy
Дата
Msg-id CAKFQuwYM5Z7iz6gLVwgxvxfsN=DwUtkPmcdsTqyPKbjWt-mnfA@mail.gmail.com
обсуждение исходный текст
Ответ на variable filename for psql \copy  (Jiří Fejfar <jurafejfar@gmail.com>)
Ответы Re: variable filename for psql \copy  (Jiří Fejfar <jurafejfar@gmail.com>)
Список pgsql-hackers
On Mon, Apr 25, 2022 at 1:24 AM Jiří Fejfar <jurafejfar@gmail.com> wrote:
contrib_regression=# copy (select 1) to :'afile';

Hopefully you realize that COPY is going to place that file on the server, not send it to the psql client to be placed on the local machine.

The best way to do copy in psql is:
\set afile '...'
\o :'afile'
copy ... to stdout; --or the variant where you one-shot the \o ( \g with arguments )

Not only do you get variable expansion but you can write the COPY command on multiple lines just like any other SQL command.

Additionally, we have a list, and even an online form, for submitting bug reports.  That would have been the more appropriate place to direct this email.

David J.

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: bogus: logical replication rows/cols combinations
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: [Proposal] vacuumdb --schema only