Using filter you could get the function you want.
Another solution is pgloader (http://pgloader.tapoueh.org) , but I don't know if it is as fast as copy.
Cheers,Another solution is pgloader (http://pgloader.tapoueh.org) , but I don't know if it is as fast as copy.
Rémi-C
2014-05-06 23:04 GMT+02:00 David G Johnston <david.g.johnston@xxxxxxxxx>:
On 5/6/2014 1:22 PM, David G Johnston wrote:if you didn't specify the columns in your file, how would you expect it
> 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?
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: Re: any psql \copy tricks for default-value columns without source data?