From: | a <372660931(at)qq(dot)com> |
---|---|
To: | amul sul <sulamul(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How do I copy an element of composite type array into csv file? |
Date: | 2018-05-23 08:47:25 |
Message-ID: | tencent_162F77570B85783C7568320B@qq.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thank you very much.
BTW, may I ask if I would like to do the opposite that copy csv file content into the first element, how should I do it??
COPY B(Ay[1])
from 'E:/products_199.csv' DELIMITER ',' CSV HEADER;
------------------ Original ------------------
From: "amul sul";<sulamul(at)gmail(dot)com>;
Send time: Wednesday, May 23, 2018 5:11 PM
To: "a"<372660931(at)qq(dot)com>;
Cc: "pgsql-general"<pgsql-general(at)postgresql(dot)org>;
Subject: Re: How do I copy an element of composite type array into csv file?
On Wed, May 23, 2018 at 2:05 PM, a <372660931(at)qq(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | tango ward | 2018-05-23 09:03:37 | Insert data if it is not existing |
Previous Message | amul sul | 2018-05-23 08:41:02 | Re: How do I copy an element of composite type array into csv file? |