Redshift で存在するテーブル、ビュー、スキーマの DROP 文を生成する
- テーブル
select 'drop table '||schemaname||'.'||tablename||' cascade;' from pg_tables where schemaname not in ('public', 'information_schema', 'catalog_history') and schemaname not like 'pg_%';
- ビュー
select 'drop view '||schemaname||'.'||viewname||';' from pg_views where schemaname not in ('public', 'information_schema', 'catalog_history') and schemaname not like 'pg_%';
select 'drop schema '||nspname||';' from pg_catalog.pg_namespace where nspname not in ('public', 'information_schema', 'catalog_history') and nspname not like 'pg_%';