PostgreSQL: SQL script to get a list of all tables that has a particular column as foreign key

前端 未结 9 951
独厮守ぢ
独厮守ぢ 2021-01-29 23:31

I\'m using PostgreSQL and I\'m trying to list all the tables that have a particular column from a table as a foreign-key/reference. Can this be done? I\'m sure this information

9条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 00:15

    Table constraints can include multiple columns. The trick to getting this right is to join each column by their constraint ordinal positions. If you don't join correctly your script will blow up with duplicate rows

提交回复
热议问题