Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgresql get tables where column is foreign key

SELECT
    r.table_name
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
WHERE
    u.column_name = 'id' AND
    u.table_catalog = 'db_name' AND
    u.table_schema = 'public' AND
    u.table_name = 'table_a'
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle run_duration average 
Sql :: partitioning in oracle-base 
Sql :: oracle index hint multiple tables example 
Sql :: dbt unique key 
Sql :: float in sql 
Sql :: group function in sql 
Sql :: sql truncate number 
Sql :: how to get alternate records from a table in sql 
Sql :: convert varchar to time sql 
Sql :: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed 
Sql :: convert sql query to laravel eloquent 
Sql :: postgres select from values 
Sql :: before delete trigger mysql 
Sql :: add 10 to all numbers in a column sql 
Sql :: python connect to mysql in settings.py 
Sql :: run sql script file and changes db name in this file using c# 
Csharp :: c# minimize form 
Csharp :: hello world program in c# 
Csharp :: regions unity 
Csharp :: c# writeline debug 
Csharp :: c# remove crlf from string 
Csharp :: fade text unity 
Csharp :: c# check if textbox is not empty 
Csharp :: c# unix timestamp 
Csharp :: stop audio unity 
Csharp :: hello world c 
Csharp :: onafterrender blazor 
Csharp :: c# summary link 
Csharp :: how to input a double in c# 
Csharp :: c# how to add newline on text box 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =