Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 572154764AC for ; Tue, 6 Aug 2002 10:01:25 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 292944763CC for ; Tue, 6 Aug 2002 10:01:15 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g76E17Vk015115; Tue, 6 Aug 2002 10:01:07 -0400 (EDT) To: Jeff Eckermann Cc: John Zhang , pgsql-sql@postgresql.org Subject: Re: copy files to postgresql In-reply-to: <20020806132325.38254.qmail@web20809.mail.yahoo.com> References: <20020806132325.38254.qmail@web20809.mail.yahoo.com> Comments: In-reply-to Jeff Eckermann message dated "Tue, 06 Aug 2002 06:23:25 -0700" Date: Tue, 06 Aug 2002 10:01:07 -0400 Message-ID: <15114.1028642467@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/89 X-Sequence-Number: 8935 Jeff Eckermann writes: > I believe that soon-to-be-released version 7.3 will > have the ability to import data to specific columns, > as you are trying to do. For now, you will have to > edit your input file to insert values (even if null) > for the missing columns. A usually-easier way is to make a temp table that matches the column format of the source file, COPY into that, and then do INSERT INTO finaltable SELECT foo,bar,... FROM temptable In the INSERT/SELECT it's trivial to do any rearrangement you want. 7.3 will add some more flexibility to COPY, but it only saves a step, doesn't really do anything you can't do with a temp table. regards, tom lane