in reply to Re: DBI:to sort tables according to their dependencies
in thread DBI:to sort tables according to their dependencies

As I understand it, pg_depend contains all links between all database objects (tables, columns, sequences, indexes, blobs, etc...); it gets used by the server to decide what all goes away when you do DROP TABLE/whatever. There may be Rather a Lot of Filtering to do to get it down to just foreign-key links between tables.

An alternative would be to start from the list of constraints in pg_constraint (link is for version 8.4; adjust accordingly if you're using some other version of postgresql)

  • Comment on Re^2: DBI:to sort tables according to their dependencies