Find the referenced table name using table, field and schema name
I have a requirement where I need to find the referenced table name (Primary key table name) by a particular field in a table (Foreign key table) using this field name, table name (where this field resides) and the schema name (where the table and thereby the field resides) For example: Schema1.TableA Id (Integer, PK) Name varchar Schema2.TableB Id (integer, PK) A_Id (integer, FK referencing TableA.Id) Name varchar I need to pass A_Id , TableB and Schema2 to a function and get Schema1.TableA as result. I am using Postgres 8.3. Erwin Brandstetter If you don't need this to be portable to another