Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgres check for 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 :: mysql alter table add column first 
Sql :: how to find sql server agent jobs related to a database 
Sql :: search for replace in mysql 
Sql :: postgres float to int 
Sql :: create table postgresql foreign key 
Sql :: min salary in sql 
Sql :: drop df constraint sql server 
Sql :: rename field name in mysql 
Sql :: order by desc postgres 
Sql :: Get the Db column names from a SqlDataReader 
Sql :: add column in sql server 
Sql :: how to drop a table in mysql 
Sql :: create stored procedure 
Sql :: how to create a table in mysql 
Sql :: select into temp table 
Sql :: sql server backup table 
Sql :: oracle pagination query rownum 
Sql :: java sql timestamp now 
Sql :: windows services sql 
Sql :: select milliseconds mysql 
Sql :: update table from another table 
Sql :: mysql get latest duplicate rows 
Sql :: if null mysql 
Sql :: check if a column is a primary key in sql server 
Sql :: multiple like in sql 
Sql :: adding constraints to columns SQL 
Sql :: oracle sql concatenate results into string 
Sql :: sql select case when 
Sql :: como saber si tengo mysql instalado 
Sql :: SQL Server Altering Column to be Unique 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =