pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: a <372660931@qq.com>
To: amul sul <sulamul@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re:  How do I copy an element of composite type array into csv file?
Date: Wed, 23 May 2018 16:47:25 +0800
Message-ID: <tencent_162F77570B85783C7568320B@qq.com> (raw)
In-Reply-To: <CAAJ_b9650QJ+WgN3NRf92148dVVi3MT-f996LR_4ksChnWEYCg@mail.gmail.com>
References: <tencent_428C1F5C4640DDCF140B725F@qq.com>
	<CAAJ_b9650QJ+WgN3NRf92148dVVi3MT-f996LR_4ksChnWEYCg@mail.gmail.com>

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@gmail.com>;
Send time: Wednesday, May 23, 2018 5:11 PM
To: "a"<372660931@qq.com>; 
Cc: "pgsql-general"<pgsql-general@postgresql.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@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

view thread (6+ messages)  latest in thread

Message-ID: <tencent_162F77570B85783C7568320B@qq.com>
Permalink:  ../tencent_162F77570B85783C7568320B@qq.com/
Also on:    postgresql.org/message-id/tencent_162F77570B85783C7568320B@qq.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: 372660931@qq.com, sulamul@gmail.com
  Subject: Re: How do I copy an element of composite type array into csv file?
  In-Reply-To: <tencent_162F77570B85783C7568320B@qq.com>
  References: <tencent_428C1F5C4640DDCF140B725F@qq.com> <CAAJ_b9650QJ+WgN3NRf92148dVVi3MT-f996LR_4ksChnWEYCg@mail.gmail.com> <tencent_162F77570B85783C7568320B@qq.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox