From: | andy <andy(at)squeakycode(dot)net> |
---|---|
To: | Kynn Jones <kynnjo(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to temporarily disable a table's FK constraints? |
Date: | 2007-11-05 22:32:59 |
Message-ID: | 472F9A1B.1020308@squeakycode.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Kynn Jones wrote:
> Hi, everyone.
>
> Is there a standard way to disable a table foreign-key constraint temporarily?
>
> I thought that this would be a fairly common thing to want to do, but
> I only found this snippet online:
>
> -- to disable
> UPDATE pg_class SET reltriggers=0 WHERE relname = 'your_table';
>
> -- to re-enable
> UPDATE pg_class SET reltriggers = count( * )
> FROM pg_trigger WHERE pg_class.oid=tgrelid AND relname = 'your_table';
>
> and it appears that one needs to be root to execute these statements.
>
> Is there any other way for non-root users?
>
> TIA!
>
> kj
Hey, I was just thinking about this... instead of disabling the FK's,
what about adding a temp table where you could COPY into, then fire off
a bunch of update's to setup the id fields, etc, etc, then do an Insert
into realtable select * from temptable?
-Andy
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2007-11-05 22:53:15 | Re: php and postgres - too many queries too fast? |
Previous Message | andy | 2007-11-05 22:29:38 | Re: php and postgres - too many queries too fast? |