Created
February 6, 2022 18:01
-
-
Save iljya/5b4c7a8eef4973e3ab5f22ae196458b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create a query to delete all tables with a certain field name. | |
select array_to_string(array_agg(cmd), '; ') from ( | |
select concat('DROP TABLE "', t.table_name, '"') as cmd | |
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 = 'geometry' | |
and t.table_schema not in ('information_schema', 'pg_catalog') | |
and t.table_type = 'BASE TABLE' | |
order by t.table_schema) as cmds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment