Find tables without foreign keys in Vertica database

Query below returns tables that don't have foreign keys.

See also:

Query

select tab.table_schema,
       tab.table_name,
       '>- no FKs' as foreign_keys
from v_catalog.tables tab
left join v_catalog.foreign_keys fks
          on tab.table_schema = fks.table_schema
          and tab.table_name = fks.table_name
where fks.constraint_id is null
order by tab.table_schema,
         tab.table_name;

Columns

  • table_schema - schema name
  • table_name - name of the table
  • foreign_keys - symbol indicating lack of FKs

Rows

  • One row represents one table that doesn't have a foreign key
  • Scope of rows: tables in a database without FKs
  • Ordered by schema and table name

Sample results

Sample result for VMart database:

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.