Re: COPY column order

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: MD33 <mdubosforum(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY column order
Date: 2012-05-07 13:13:05
Message-ID: 4FA7CA61.4020003@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/07/2012 05:33 AM, MD33 wrote:
> Hi there
>
> I'm trying to use COPY with HEADER option but my header line in file is in
> different order than the column order specified in database.
> Is the column name order necessary in my file ??

From the docs:
http://www.postgresql.org/docs/9.0/interactive/sql-copy.html
"HEADER
Specifies that the file contains a header line with the names of each
column in the file. On output, the first line contains the column names
from the table, and on input, the first line is ignored. This option is
allowed only when using CSV format."

So when going from file to table the HEADER is ignored, The column order
is important though. This can be specified by using the column parameter.

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-05-07 13:33:45 Re: Streaming replication: sequences on slave seemingly ahead of sequences on master
Previous Message MD33 2012-05-07 12:33:46 COPY column order