Query below allow to get number of references from tables.
See also:
Query
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,
table_name
order by count(*) desc;
Columns
- 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)
Rows
- One row represents one table
- Scope of rows: all tables which are referencing to tables
- Ordered by count of foreign keys descending