Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pcbldi/fcdded33cfc454bf5d9f5dd9144b1525 to your computer and use it in GitHub Desktop.
Save pcbldi/fcdded33cfc454bf5d9f5dd9144b1525 to your computer and use it in GitHub Desktop.
Drop all tables and sequences in postgres
# tables for owned by 'tableowner'
select 'drop table if exists "' || tablename || '" cascade;' from pg_tables where tableowner='tableowner';
# all sequences
select 'drop sequence if exists "' || relname || '" cascade;' from pg_class where relkind = 'S';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment