Re: Conflict between JSON_AGG and COPY

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Conflict between JSON_AGG and COPY
Дата
Msg-id 089767b9-d84c-498f-6ad7-412e054d592a@aklaver.com
обсуждение исходный текст
Ответ на Re: Conflict between JSON_AGG and COPY  (Đỗ Ngọc Trí Cường <dntcuong@digi-texx.vn>)
Ответы Re: Conflict between JSON_AGG and COPY  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
On 04/08/2018 08:44 PM, Đỗ Ngọc Trí Cường wrote:
> Dear Arian Klaver,
> 
> I think there is a misunderstood here.
> 
> I think that I quite understand how is the second query run.
> 
> The question I asked here is why exporting data, which is generated by a 
> query "JSON_AGG" , with command "COPY". The data contain "\n" as 2 
> characters instead of "new line" character.

https://www.postgresql.org/docs/10/static/sql-copy.html

File Formats
Text Format

"
\n     Newline (ASCII 10)

Presently, COPY TO will never emit an octal or hex-digits backslash 
sequence, but it does use the other sequences listed above for those 
control characters.

...

COPY TO will terminate each row with a Unix-style newline (“\n”).
"

> 
> The second query is for the old version of PostgreSQL (9.3 and previous) 
> cause of they don't have JSON_AGG aggregate function. Since 9.4, we have 
> "JSON_AGG" already. So I want to rewrite and reduce the length of the 
> query. But it is don't work as I expected with command COPY.
> 
> Thank you and best regards,
> 
> 
> Đỗ Ngọc Trí*Cường*(Mr.) | *Software Development Department*| +84 28 3715 
> 5325

-- 
Adrian Klaver
adrian.klaver@aklaver.com


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

Предыдущее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Rationale for aversion to the central database?
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Conflict between JSON_AGG and COPY