Find tables without foreign keys in Vertica database

Bart Gawrych - Dataedo Team Bart Gawrych 2019-10-31

Table of Contents:

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

    See also:


    select tab.table_schema,
           '>- 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,


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


    • 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:

    There are no comments. Click here to write the first comment.

    By continuing to use our website, you consent to the use of cookies in accordance with our Privacy Policy (updated 28-04-2020).