Re: any psql \copy tricks for default-value columns without source data?

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: any psql \copy tricks for default-value columns without source data?
Date: 2014-05-06 21:04:11
Message-ID: CAKFQuwb41x2e6mm-aPYnLW6Y-erxz7gHR+0hCi=dBgK+Edg3bw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 6, 2014 at 4:48 PM, John R Pierce [via PostgreSQL] <
ml-node+s1045698n5802802h86(at)n5(dot)nabble(dot)com> wrote:

> On 5/6/2014 1:22 PM, David G Johnston wrote:
> > I know that I can pre-process the input file and simply add the needed
> data
> > but I am curious if maybe there is some trick to having defaults
> populate
> > for missing columns WITHOUT explicitly specifying each and every column
> that
> > is present?
>
> if you didn't specify the columns in your file, how would you expect it
> to know whats there and not there?
>
>
​The default copy behavior is column-order dependent. If your input file
has 10 columns and the table has 10 columns they get matched up 1-to-1 and
everything works just fine. It would be nice if there was some way to say
that if the table has 12 columns but the file has 10 columns that the first
10 columns of the table get matched to the file and the remaining two
columns use their default values; that way you can add default columns to
the end of the table and still do an auto-matching import.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/any-psql-copy-tricks-for-default-value-columns-without-source-data-tp5802795p5802804.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Glen Eustace 2014-05-06 21:22:04 Re: Monitoring Pg servers with Microsoft SCOM
Previous Message John R Pierce 2014-05-06 20:47:19 Re: any psql \copy tricks for default-value columns without source data?