Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 11C069FB8B8 for ; Mon, 7 May 2007 23:44:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 15418-01 for ; Mon, 7 May 2007 23:44:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from rrmailscan3.safenetbox.biz (unknown [203.25.40.75]) by postgresql.org (Postfix) with ESMTP id C98269FB33A for ; Mon, 7 May 2007 23:44:31 -0300 (ADT) Received: from rrmailscan3.safenetbox.biz (rrmailscan3.safenetbox.biz [127.0.0.1]) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id BFA361D4842E for ; Tue, 8 May 2007 12:44:29 +1000 (EST) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (Authenticated sender: remote) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id D14FF1D4844C for ; Tue, 8 May 2007 12:44:28 +1000 (EST) Message-ID: <463FE405.40704@autoledgers.com.au> Date: Tue, 08 May 2007 10:44:21 +0800 From: Paul Lambert User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Query RE using COPY References: <463FD7B8.9030700@autoledgers.com.au> <36e682920705071916l27d64129j2d3c9d296fbbd6e5@mail.gmail.com> In-Reply-To: <36e682920705071916l27d64129j2d3c9d296fbbd6e5@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/54 X-Sequence-Number: 28335 Jonah H. Harris wrote: > COPY mytbl (col1, col2, col3, col4, col6) FROM 'myfile.txt' WITH > DELIMITER AS '^' QUOTE '\f' CSV HEADER; > > I would rather not do it this way as I use the same load script at all customer sites where the extracts and requirements may vary. I.e. one customer may not use the location field mentioned above, but another might. What I would prefer to do, if possible, is set that column in the database to 'not required' so that if I get an extract that doesn't have that column in the file, the copy doesn't care. As it stands now I generally have to drop all the unneeded columns from numerous tables, perform my load and then re-add them back again. When we're talking about 40 or more tables in each database some tables with several hundred columns... your suggestion would be a bit cumbersome - particularly if it is only one or two columns in each table that that the client doesn't need. -- Paul Lambert Database Administrator AutoLedgers