Query below lists all not referenced tables by any foreign key.
See also:
Query
select '>- no FKs' as foreign_keys,
tab.table_schema,
tab.table_name
from v_catalog.tables tab
left join v_catalog.foreign_keys fks
on tab.table_schema = fks.reference_table_schema
and tab.table_name = fks.reference_table_name
where fks.constraint_id is null
order by tab.table_schema,
tab.table_name;
Columns
- foreign_keys - symbol indicating lack of FK references
- table_schema - name of the schema
- table_name - table name
Rows
- One row represents one table
- Scope of rows: tables in a database which are not referenced by any foreign key
- Ordered by table schema, table name
Sample results
Tables in VMart not referenced by foreign keys: