Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save medyo/fad03c9c4173e7c84f1ffae0d06f9af8 to your computer and use it in GitHub Desktop.
Save medyo/fad03c9c4173e7c84f1ffae0d06f9af8 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