postgres check for foreign key

Hello guys! In this post I have shared the details about “postgres check for foreign key”. Okay, let’s move on to the article.

postgres check for foreign key

FROM information_schema.constraint_column_usage       u
INNER JOIN information_schema.referential_constraints fk
           ON u.constraint_catalog = fk.unique_constraint_catalog
               AND u.constraint_schema = fk.unique_constraint_schema
               AND u.constraint_name = fk.unique_constraint_name
INNER JOIN information_schema.key_column_usage        r
           ON r.constraint_catalog = fk.constraint_catalog
               AND r.constraint_schema = fk.constraint_schema
               AND r.constraint_name = fk.constraint_name
    u.column_name="id" AND
    u.table_catalog = 'db_name' AND
    u.table_schema="public" AND


I hope this tutorial helps you to know about “postgres check for foreign key”. If you have any doubts regarding this article please let us know via the comment section. Share this article with your friends & family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment