Created
August 7, 2012 09:40
-
-
Save dsci/3283942 to your computer and use it in GitHub Desktop.
Dropping all tables in a PostgreSQL database
This file contains hidden or 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
# first, login with psql | |
psql -U USERNAME -d databasename | |
# set output for all queries | |
\o FILENAME.sql | |
# run this query | |
select 'drop table ' || tablename || ' cascade;' from pg_tables; | |
# logout from psql | |
\q | |
# run sql script from commandline | |
psql -U USERNAME -d databasename -f FILENAME.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment