Skip to content

Instantly share code, notes, and snippets.

@lamogura
Created September 13, 2016 02:13
Show Gist options
  • Select an option

  • Save lamogura/2e0553e453602a4daca31d4e971cd7b6 to your computer and use it in GitHub Desktop.

Select an option

Save lamogura/2e0553e453602a4daca31d4e971cd7b6 to your computer and use it in GitHub Desktop.
drop all tables in postgres db
psql -h <pg_host> -p <pg_port> -U <pg_user> <pg_db> -t -c "select 'drop table \"' || tablename || '\" cascade;' from pg_tables where schemaname='public'" | psql -h <pg_host> -p <pg_port> -U <pg_user> <pg_db>
// remember to have the password set in .pgpass file, host:port:db:user:pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment