Query below lists tables that are most referenced by other tables with foreign keys.
select reference_table_schema || '.' || reference_table_name as table, count(*) as references, count(distinct table_schema ||'.'|| table_name) as referencing_tables from v_catalog.foreign_keys group by reference_table_schema, reference_table_name order by reference_table_schema, reference_table_name;
- table - name of the table with schema name
- references - number of foreign keys referencing to this table
- referencing_tables - number of different tables referencing to this table
- One row represents one table in a database
- Scope of rows: tables being used in foreign keys as primary key table
- Ordered by number of references descending