Skip site navigation (1) Skip section navigation (2)

Re: How to add constraints without validating data.

From: Nilesh Govindarajan <lists(at)itech7(dot)com>
To: Amit jain <amitjain(at)synechron(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: How to add constraints without validating data.
Date: 2010-05-27 12:34:35
Message-ID: AANLkTik0wf-id2BZslZxbOuDRZNkD6zMVlMVuS7Qdb0I@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
On Thu, May 27, 2010 at 5:55 PM, Amit jain <amitjain(at)synechron(dot)com> wrote:
> 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
>
>


I don't think there's any method to do that. If you add a constraint
using ALTER TABLE it will check existing data also. One option is you
create a new table with the constraints and same column names then:

insert into newtable values ( select * from oldtable)

but again this will check for old data, but may be faster.

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

In response to

pgsql-admin by date

Next:From: Johann SpiesDate: 2010-05-27 14:31:40
Subject: Re: Corrupted database - how to recover
Previous:From: Amit jainDate: 2010-05-27 12:25:56
Subject: How to add constraints without validating data.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group