List all tables refrencing specific table (by FK) in Vertica database

This query allows to find all tables which are referencing to specific table.

Query

select distinct table_schema || '.' || table_name  as fk_table_name,
       '>-' as rel,
       reference_table_schema || '.' || reference_table_name
            as primary_table
from v_catalog.foreign_keys 
where reference_table_name = 'product_dimension'
      -- and reference_table_schema = 'schema_name'
order by fk_table_name;

Columns

  • foreign_table - table schema followed by table name - table we look for
  • ref - relationship symbol implicating FK and direction
  • primary_table - primary table name with schema name - table provided as a parameter

Rows

  • One row represents one referencing table
  • Scope of rows: all tables referencing table with provided name (and optionally schema)
  • Ordered by referencing table schema and name

Sample results

Tables that refers to public.product_dimension table with FK in VMart database .

0
There are no comments. Click here to write the first comment.