Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 3784A9FB276 for ; Tue, 21 Nov 2006 18:19:18 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 41438-01 for ; Tue, 21 Nov 2006 22:19:12 +0000 (UTC) X-Greylist: delayed 01:00:07.969733 by SQLgrey- Received: from misuse.org (misuse.org [64.62.234.92]) by postgresql.org (Postfix) with SMTP id C10D09FB26E for ; Tue, 21 Nov 2006 18:19:11 -0400 (AST) Received: from dino-1.misuse.org ([68.122.68.247]) by misuse.org for ; Tue, 21 Nov 2006 11:13:28 -0800 X-Mailer: QUALCOMM Windows Eudora Version 7.1.0.9 Date: Tue, 21 Nov 2006 11:13:26 -0800 To: pgsql-sql@postgresql.org From: Steve Midgley Subject: "Copy from" omit source columns? Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Message-Id: <20061121221911.C10D09FB26E@postgresql.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.343 tagged_above=0 required=5 tests=BAYES_40, FORGED_RCVD_HELO, MSGID_FROM_MTA_ID X-Spam-Level: * X-Archive-Number: 200611/224 X-Sequence-Number: 26876 Hello, (I already fear the answer to my question is "no..") :) I am using the 'COPY FROM' SQL command (not psql \copy) to move data into a table from a CSV file. The source data are suitable for import EXCEPT there are extraneous columns of data in the source file. In essence, my table schema is: id, col1, col2, col4 My source file schema is: col1,col2,col3,col4 I'm curious if there is any way to tell "COPY" to ignore the third column of data? Basically I'd like to write something along the lines of: copy import (col1,col2,\n,col4) from 'c:/dev/import/source/test.csv' with CSV HEADER Note "\n" would indicate there there is a column in the source that should simply be ignored during the import. Of course, I tried this syntax and it didn't work. Perhaps there is another way of indicating that there is a "null column" in the source file that should be skipped during import? Any assistance in solving this problem (without having to change the source file) would be greatly appreciated. If I have to change the source file, I will, but it would greatly simplify things if I didn't have to.. Best regards and thanks for any ideas, Steve