Skip to content

Instantly share code, notes, and snippets.

@smerchek
Last active July 9, 2019 16:13
Show Gist options
  • Select an option

  • Save smerchek/93d265b6feb95311321a7e4834bd256f to your computer and use it in GitHub Desktop.

Select an option

Save smerchek/93d265b6feb95311321a7e4834bd256f to your computer and use it in GitHub Desktop.
Find all tables with a given column name (e.g. `is_removed`)
select t.table_schema,
t.table_name
from information_schema.tables t
inner join information_schema.columns c on c.table_name = t.table_name
and c.table_schema = t.table_schema
where c.column_name = 'is_removed'
and t.table_schema not in ('information_schema', 'pg_catalog')
and t.table_type = 'BASE TABLE'
order by t.table_schema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment