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

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 'MODIFIEDDATE' column.

Query

select t.table_schema, 
       t.table_name
from information_schema.tables t
left outer join 
    (select table_schema, table_name
     from information_schema.columns
     where column_name ='MODIFIEDDATE'
     ) c on c.table_schema = t.table_schema and c.table_name = t.table_name
where t.table_type = 'BASE TABLE'
and c.table_name is null
order by t.table_schema, 
       t.table_name; 

Columns

  • schema_name - 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, table name

Sample results

These tables do not have a 'MODIFIEDDATE' column.

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.