pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dmitry Tkach <dmitry@openratings.com>
To: rute solipa <rutes@eselx.ipl.pt>
Subject: Re: disable constraints
Date: Fri, 28 Feb 2003 17:42:00 -0500
Message-ID: <3E5FE5B8.6080405@openratings.com> (raw)
In-Reply-To: <5.1.1.6.0.20030226151506.026d0a38@mail.eselx.ipl.pt>
References: <5.1.1.6.0.20030226151506.026d0a38@mail.eselx.ipl.pt>

rute solipa wrote:
> i whant avoid to dropping constraint, i whant to disable the constraints, 
> because i need to insert a large amont of data.
> is there a way?
> 
> best regards,
> rute
> 
> 

There is no "oficial" way to do that, as far as I know...
You can disable *triggers* on a table (which will disable all the FK constraints, but not things like 'not nul' or 'unique'), by doing:

update pg_class set reltriggers=0 where relname = 'YOUR_TABLE_NAME';

to enable them after you are done, do

update pg_class set reltriggers = count(*) from pg_trigger where pg_class.oid=tgrelid and relname='YOUR_TABLE_NAME';

I hope, it helps...

Dima


> 
> At 03:47 PM 2/26/2003 +0100, you wrote:
> 
>>Hi!
>>
>>use "alter table ??? drop constraint ???"
>>
>>example:
>>
>>create table asdf (userid text, foreign key (userid) references 
>>person(userid) on delete cascade);
>>
>>\d asdf
>>    Table "public.asdf"
>> Column | Type | Modifiers
>>--------+------+-----------
>> userid | text |
>>Foreign Key constraints: $1 FOREIGN KEY (userid) REFERENCES person(userid) 
>>ON UPDATE NO ACTION ON DELETE CASCADE
>>
>>alter table asdf drop constraint "$1";
>>
>>Regards,
>>Patrik Kudo
>>
>>rute solipa wrote:
>>
>>>hello,
>>>does anyone nows how can i disable/enable table or column constraints?
>>>in oracle it's possible to disable constraints like this:
>>>alter table tb_1
>>>disable primary key;
>>>best regards,
>>>rute
>>>
>>>---------------------------(end of broadcast)---------------------------
>>>TIP 3: if posting/reading through Usenet, please send an appropriate
>>>subscribe-nomail command to majordomo@postgresql.org so that your
>>>message can get through to the mailing list cleanly
>>
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org




view thread (5+ messages)  latest in thread

Message-ID: <3E5FE5B8.6080405@openratings.com>
Permalink:  ../3E5FE5B8.6080405@openratings.com/
Also on:    postgresql.org/message-id/3E5FE5B8.6080405@openratings.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dmitry@openratings.com, rutes@eselx.ipl.pt
  Subject: Re: disable constraints
  In-Reply-To: <3E5FE5B8.6080405@openratings.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox