Deleting foreign key constraints

Started by Nikhil G. Daddikarover 23 years ago3 messagesgeneral
Jump to latest
#1Nikhil G. Daddikar
ngd@celoxis.com

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.

#2Christoph Dalitz
christoph.dalitz@hs-niederrhein.de
In reply to: Nikhil G. Daddikar (#1)
Re: Deleting foreign key constraints

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

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Nikhil G. Daddikar (#1)
Re: Deleting foreign key constraints

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.

Show quoted text

I am using 7.1.3