Обсуждение: Deleting foreign key constraints

Поиск
Список
Период
Сортировка

Deleting foreign key constraints

От
"Nikhil G. Daddikar"
Дата:
Hello,

Is there a way to delete all foreign key constraints for a table?

Also, is there a way to programmatically find all tables (excluding
system created) in a database?

I am using 7.1.3

Thanks much.




Re: Deleting foreign key constraints

От
Christoph Dalitz
Дата:
On Thu, 29 Aug 2002 05:44:14 -0400
pgsql-general-owner@postgresql.org wrote:
>
> Is there a way to delete all foreign key constraints for a table?
>
"ALTER <table> DROP <constraint>" should do it. See the SQL command reference
for details.

> Also, is there a way to programmatically find all tables (excluding
> system created) in a database?
>
Call psql qith the "-E" option and enter "\d".
Then psql will echo the internal SQL-commands used for collecting the info.

Christoph Dalitz

Re: Deleting foreign key constraints

От
Stephan Szabo
Дата:
On Thu, 29 Aug 2002, Nikhil G. Daddikar wrote:

> Is there a way to delete all foreign key constraints for a table?

Not a particularly good one.  You'll probably need to drop the triggers
manually (from both that table and the table it references) and you'll
need to match up the arguments to do that.  There's some info on
techdocs.postgresql.org about the triggers that you might find useful.

> Also, is there a way to programmatically find all tables (excluding
> system created) in a database?

Check the query generated by psql for a \d (use psql -E to get the
the query).  It'll be something with pg_class.

>
> I am using 7.1.3