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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…