Re: Diabling constraints

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Diabling constraints
Дата
Msg-id Pine.BSF.4.21.0109142259130.46304-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Diabling constraints  (Linh Luong <linh.luong@computalog.com>)
Список 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.



В списке pgsql-general по дате отправления:

Предыдущее
От: Alex Pilosov
Дата:
Сообщение: CLUSTER (was Re: get certain # of recs)
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Abort state on duplicated PKey in transactions