http://www.perlmonks.org?node_id=944543

ansh batra has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

i have a method which return the list of tables present in a schema, now what I need is to sort this list according to their dependencies i.e if x have foreign key which uses y then the list will have x before y.(where x and y are the tables in the schema).



i am using select tablename from pg_tables where schemaname='schemaname' command to get the list of tables
please help