Received: from maia.hub.org (maia-4.hub.org [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id CFC8B6329B7 for ; Sun, 16 May 2010 21:32:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 84562-07 for ; Mon, 17 May 2010 00:32:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id F0721632989 for ; Sun, 16 May 2010 21:32:11 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1ODoFe-00024y-83 for pgsql-sql@postgresql.org; Mon, 17 May 2010 02:32:10 +0200 Received: from g224127222.adsl.alicedsl.de ([92.224.127.222]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 May 2010 02:32:10 +0200 Received: from tim by g224127222.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 May 2010 02:32:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org connect(): No such file or directory From: Tim Landscheidt Subject: Re: import ignoring duplicates Date: Mon, 17 May 2010 00:32:00 +0000 Organization: Lines: 22 Message-ID: References: <4BF03B89.9020908@noaa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: g224127222.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:ncmIPgu8mR6tvXoBxbt3irGN2w4= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/73 X-Sequence-Number: 34121 Mark Fenbers wrote: > I am using psql's \copy command to add records to a database > from a file. The file has over 100,000 lines. > Occasionally, there is a duplicate, and the import ceases > and an internal rollback is performed. In other words, no > data is imported even if the first error occurs near the end > of the file. > I am looking for an option/switch to tell psql (or the \copy > command) to skip over any duplicate key constraint > viloations and continue to load any data that doesn't > violate a duplicate key constraint. Is there such an > option? No. You can either disable the constraint temporarily, im- port the data, fix any duplicates and re-enable the con- straint, or you can load the data in a temporary table and then transfer only the valid data. With only 100000 records I would opt for the latter. Tim