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

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

Table of Contents:


    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:

    0
    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).
    Accept