Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 06015632979 for ; Thu, 27 May 2010 13:01:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 41730-04 for ; Thu, 27 May 2010 16:01:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from hermes.vectorsf.com (firewall.vectorsf.com [62.82.80.62]) by mail.postgresql.org (Postfix) with ESMTP id 6F97F632904 for ; Thu, 27 May 2010 13:01:02 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by hermes.vectorsf.com (Postfix) with ESMTP id 96B99248000B; Thu, 27 May 2010 18:00:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at hermes.vectorsf.com Received: from hermes.vectorsf.com ([127.0.0.1]) by localhost (hermes.vectorsf.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IpHuidFsTL4c; Thu, 27 May 2010 18:00:52 +0200 (CEST) Received: from [10.70.4.200] (unknown [10.70.4.200]) (Authenticated sender: imartinez) by hermes.vectorsf.com (Postfix) with ESMTP id 1F72F2480006; Thu, 27 May 2010 18:00:52 +0200 (CEST) Subject: Re: How to add constraints without validating data. From: =?ISO-8859-1?Q?I=F1igo?= Martinez Lasala To: Amit jain Cc: pgsql-admin@postgresql.org In-Reply-To: <4BFE64D4.4020107@synechron.com> References: <4BFE64D4.4020107@synechron.com> Content-Type: multipart/alternative; boundary="=-a+zbPXXLsbUI+qb0aPco" Date: Thu, 27 May 2010 18:00:54 +0200 Message-ID: <1274976054.19383.37.camel@deimos> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.791 tagged_above=-10 required=5 tests=BAYES_50=0.8, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/265 X-Sequence-Number: 34738 --=-a+zbPXXLsbUI+qb0aPco Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit You have to disable triggers. Two options: - Export table data, truncate table (if your table is fk source you will have a problem), add constraint and import exported data with --disable-triggers flag in pg_restore. - Perhaps you could add manually triger via pg_trigger table in pg_catalog whith an insert into this table. -----Original Message----- From: Amit jain To: pgsql-admin@postgresql.org Subject: [ADMIN] How to add constraints without validating data. Date: Thu, 27 May 2010 17:55:56 +0530 Hi Gurus Is there any way in postgreSQL to apply constraints forcefully without checking/validating Data ? It should validate only those records which comes after constraints are applied. I need this help as data is already loaded in database but "ALTER TABLE" sql for adding CONSTRAINTS is taking enormous time. Thanks for ideas/suggestion in Advance !! -- Regards, Amit Jain Synechron Technologies Pvt. Ltd. 4th Floor, B Wing, Block 1.2, Embassy Techzone, Rajiv Gandhi Infotech Park, Hinjewadi Phase II, Pune 411 057. Phone : +91.20.40262000 Ext 2163 | Mobile:+91.9561298565 | VoIP : +1.732.415.0894 http://www.synechron.com MailTo: amitjain@synechron.com --=-a+zbPXXLsbUI+qb0aPco Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit You have to disable triggers.

Two options:

- Export table data, truncate table (if your table is fk source you will have a problem), add constraint and import exported data with --disable-triggers flag in pg_restore.

- Perhaps you could add manually triger via pg_trigger table in pg_catalog whith an insert into this table.

-----Original Message-----
From: Amit jain <amitjain@synechron.com>
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: [ADMIN] How to add constraints without validating data.
Date: Thu, 27 May 2010 17:55:56 +0530

Hi Gurus

Is there any way in postgreSQL to apply constraints forcefully without checking/validating Data ? It should validate only those records which comes after constraints are applied.

I need this help as data is already loaded in database but "ALTER TABLE" sql for adding CONSTRAINTS is taking enormous time.

Thanks for ideas/suggestion in Advance !!


--
Regards,

Amit Jain 
Synechron Technologies Pvt. Ltd. 4th  Floor, B Wing, Block 1.2, Embassy Techzone,
Rajiv Gandhi Infotech Park, Hinjewadi Phase II, Pune 411 057. 
Phone : +91.20.40262000 Ext 2163 | Mobile:+91.9561298565 | VoIP : +1.732.415.0894
http://www.synechron.com  MailTo: amitjain@synechron.com




--=-a+zbPXXLsbUI+qb0aPco--