Skip to content

Instantly share code, notes, and snippets.

@alazyer
Last active August 29, 2015 14:04
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 alazyer/d2275d27b53cf115351b to your computer and use it in GitHub Desktop.
Save alazyer/d2275d27b53cf115351b to your computer and use it in GitHub Desktop.
recreate database based on template database on postgresql
As the template database can't be deleted directly, so should change it into non-template database first;
$ psql -U postgres postgres
$ update pg_database set datistemplate='f' where datname='template_database';
$ drop database template_database;
create a database based on the defined template database;
$ createdb -T template_database newdatabase;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment