Re: How to add constraints without validating data.

From: Nilesh Govindarajan <lists(at)itech7(dot)com>
To: Iñigo Martinez Lasala <imartinez(at)vectorsf(dot)com>
Cc: Amit jain <amitjain(at)synechron(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: How to add constraints without validating data.
Date: 2010-05-27 16:15:25
Message-ID: AANLkTilVBVMQF7wEmRgQRqEUKf1YQYQ4Jc3tdIV_dqbV@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Thu, May 27, 2010 at 9:30 PM, Iñigo Martinez Lasala
<imartinez(at)vectorsf(dot)com> wrote:
> 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(at)synechron(dot)com>
> To: pgsql-admin(at)postgresql(dot)org <pgsql-admin(at)postgresql(dot)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(at)synechron(dot)com
>
>
>
>
>

How would disabling triggers help that ? He just wants to add
constraints without loss of data. I don't think he has any triggers.

--
Nilesh Govindarajan
Facebook: nilesh.gr
Twitter: nileshgr
Website: www.itech7.com

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Iñigo Martinez Lasala 2010-05-27 16:19:49 Re: How to add constraints without validating data.
Previous Message Iñigo Martinez Lasala 2010-05-27 16:00:54 Re: How to add constraints without validating data.