Re: [GENERAL] COPY to question

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Re: [GENERAL] COPY to question
Дата
Msg-id CAEfWYyy3ar0Na1Ox4Oe6JjV_11BEp8dDnXVFW1FH7KXeEbB8iw@mail.gmail.com
обсуждение исходный текст
Ответ на [GENERAL] COPY to question  (Rich Shepard <rshepard@appl-ecosys.com>)
Список pgsql-general
On Tue, Jan 17, 2017 at 10:23 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:
  Running -9.6.1. I have a database created and owned by me, but cannot copy
a table to my home directory. Postgres tells me it cannot write to that
directory. The only way to copy tables to files is by doing so as the
superuser (postgres).

  Why is this, and can I change something so I, as a user, can copy tables
directly to ~/?


Note that you can invoke SQL COPY to STDOUT as in: COPY (some arbitrary query) TO STDOUT;

You would either pipe/redirect the output of psql as desired or use the "\o" within psql to reroute the output to a file or pipe to a program, for example, output to a CSV using a pipe as the delimiter and double-quote as the quote character but change all "ma" to "pa" and put into myoutput.txt

\o | sed s/ma/pa/g > myoutput.txt
copy (some query) to stdout csv header delimiter '|' quote '"';
\o

Cheers,
Steve


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

Предыдущее
От: Melvin Davidson
Дата:
Сообщение: Re: [GENERAL] Queries are taking way longer in 9.6 than 9.5
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: [GENERAL] Queries are taking way longer in 9.6 than 9.5