From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Linh Luong <linh(dot)luong(at)computalog(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Diabling constraints |
Date: | 2001-09-15 06:04:01 |
Message-ID: | Pine.BSF.4.21.0109142259130.46304-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 14 Sep 2001, Linh Luong wrote:
> I am wondering is there any way of disabling constraints that was
> created after the table itself was created.
>
> I know I can drop the trigger that the constraint creates. However, I
> need to make this change in several postgres database and it seems like
> the the tgname that is required to remove the constraint is generate by
> the system so I can't just go
> drop trigger "<tgname>" on <tablename> because tgname is different in
> all the database I need to modify.
>
> Any ideas in disabling or removing them without harding the tgname..
Under 7.2, you should be able to use drop constraint/add constraint to
drop/re-add the constraint by its constraint name.
Under 7.1 and earlier:
If you're okay with turning off all triggers, you can do something
like:
-- Turn off
UPDATE "pg_class" SET "reltriggers" = 0 WHERE "relname" = '<tablename>';
... do stuff ...
-- Enable triggers
UPDATE pg_class SET reltriggers = (SELECT count(*) FROM pg_trigger where
pg_class.oid = tgrelid) WHERE relname = '<tablename>';
Otherwise, you could remove the triggers with a delete from pg_trigger
where the tgrelid is the table's id and the constraint name matches,
followed by the second update above to reset the trigger number.
From | Date | Subject | |
---|---|---|---|
Next Message | Gaurav Priyolkar | 2001-09-15 08:15:27 | Re: error while generating and EXECUTEing a query dynamically |
Previous Message | Gunnar Rønning | 2001-09-15 04:00:03 | Re: How to make a REALLY FAST db server? |