Find table that DON'T have a column with specific name in Vertica database

Databases often have standard columns. Examples of such standard columns can be id, modified_date, created_by or row_version.

Query below finds all tables that do not have a 'first_name' column.

Query

select t.table_schema,
       t.table_name
from v_catalog.tables t
left join v_catalog.columns c
          on t.table_id = c.table_id
          and c.column_name like 'first_name'
where column_name is null
order by t.table_schema,
         t.table_name;

Columns

  • table_schema - name of schema of found table
  • table_name - name of found table

Rows

  • One row represents a table
  • Scope of rows: all found tables
  • Ordered by schema name

Sample results

These tables do not have a 'first_name' column.