Re: How do I copy an element of composite type array into csv file? - Mailing list pgsql-general

From amul sul
Subject Re: How do I copy an element of composite type array into csv file?
Date
Msg-id CAAJ_b9650QJ+WgN3NRf92148dVVi3MT-f996LR_4ksChnWEYCg@mail.gmail.com
Whole thread Raw
In response to How do I copy an element of composite type array into csv file?  ("a" <372660931@qq.com>)
Responses Re: How do I copy an element of composite type array into csv file?  ("a" <372660931@qq.com>)
List pgsql-general
On Wed, May 23, 2018 at 2:05 PM, a <372660931@qq.com> wrote:
> Hi suppose I have composite type and table
>
> create type A as(
>     x float8,
>     y float8
> );
>
> create table B(
>     Ay A[]
> );
>
> insert into B
> values(array[
>     (1,2)::A,
>     (3,4)::B]
> );
>
> Now I would like to export the first element of table B into an csv file:
>
> COPY B(Ay[1])
> to 'E:/products_199.csv'  DELIMITER ',' CSV HEADER;
>
> The code above reported an syntax error.
>
> How should I do it??
>

Try COPY (SELECT Ay[1] FROM B) to 'E:/products_199.csv'  DELIMITER ','
CSV HEADER;

Regards,
Amul


pgsql-general by date:

Previous
From: "a"
Date:
Subject: How do I copy an element of composite type array into csv file?
Next
From: "a"
Date:
Subject: Re: How do I copy an element of composite type array into csv file?