Thread: Adjustment to "Problem with dropping a FOREIGN KEY"

Adjustment to "Problem with dropping a FOREIGN KEY"

From
Harry Yau
Date:
Dear:
    Hi everybody, I've just found the pg_trigger and pg_class, but I am
wondering how can i modify this two file. I've used VI to view it, but
it appear in some strange font of character. Now, I start wonder are
they actually text files or application program.
If they were files, please tell me how can I delete or modify the
context of these two file; otherwise, please show me how may I use them
to drop the constraint trigger that was created by add foreign key.

Thank A Lot
Harry Yau


Re: Adjustment to "Problem with dropping a FOREIGN KEY"

From
"Richard Huxton"
Date:
From: "Harry Yau" <harry.yau@regaltronic.com>

> Dear:
>     Hi everybody, I've just found the pg_trigger and pg_class, but I am
> wondering how can i modify this two file. I've used VI to view it, but
> it appear in some strange font of character. Now, I start wonder are
> they actually text files or application program.
> If they were files, please tell me how can I delete or modify the
> context of these two file; otherwise, please show me how may I use them
> to drop the constraint trigger that was created by add foreign key.

They're database tables - don't use a text editor on them!

You can get a listing of all the system tables with \dS - they should all
begin with pg_

You can use normal queries to update the pg_triggers and pg_class tables (if
you have the right permissions - database owner should be good). You might
want to pg_dump things first in case of any problems.

Basically, I think postgres gets confused if the reltriggers count is zero
while you still have a trigger left in pg_triggers.

There is some information on system tables in the developer's docs at
www.postgresql.org

- Richard Huxton