List tables with most foreign keys in Vertica database

Query below allow to get number of references from tables.

See also:


select table_schema || '.' || table_name
            as table,
       count(*) as foreign_keys,
       count(distinct reference_table_schema ||'.'|| reference_table_name)
            as referenced_tables
from v_catalog.foreign_keys
group by table_schema,
order by count(*) desc;


  • table_name - schema name followed with table name
  • foreign_keys - number of FKs in a table
  • referenced_tables - count of referenced tables. (Many foreign keys can reference to the same table)


  • One row represents one table
  • Scope of rows: all tables which are referencing to tables
  • Ordered by count of foreign keys descending

Sample results

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