Find tables that are not referenced by the foreign keys in Vertica database

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:

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.