Created
June 10, 2014 13:50
-
-
Save fragoulis/64faebfb932b6a383b7f to your computer and use it in GitHub Desktop.
Postgres dropdb/createdb alternative when there is no maintenance database available to connect to
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
set PGPASSWORD=password psql --host=host --username=username --command="drop schema public cascade;create schema public;" database |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was using
dropdb
andcreatedb
to recreate a whole database whenever I needed to do a complete clean up for my under development project.I came across a situation where I was not able to connect using the (default) maintenance database (which is
template1
in 9.2, for more read here). So to make drop/create work without the maintenance database I had to improvise. I connected to the database I wanted to drop, and I dropped/recreated the public schema instead.