X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E4BF447638E for ; Fri, 28 Feb 2003 17:15:24 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 43734-02 for ; Fri, 28 Feb 2003 17:15:14 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 6192A476295 for ; Fri, 28 Feb 2003 16:04:36 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 4685C43A611; Fri, 28 Feb 2003 16:04:36 -0500 (EST) From: Dmitry Tkach X-Newsgroups: comp.databases.postgresql.sql Subject: Re: disable constraints Date: Fri, 28 Feb 2003 17:42:00 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 71 Message-ID: <3E5FE5B8.6080405@openratings.com> References: <5.1.1.6.0.20030226151506.026d0a38@mail.eselx.ipl.pt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org To: rute solipa User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en In-Reply-To: <5.1.1.6.0.20030226151506.026d0a38@mail.eselx.ipl.pt> To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/625 X-Sequence-Number: 12023 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