sqldatabasepostgresqldropdatabase-template

How to drop a template database from PostgreSQL?


postgres=# DROP DATABASE template_postgis;
ERROR:  cannot drop a template database

http://www.postgresql.org/docs/9.1/static/manage-ag-templatedbs.html makes it seem like if I set template_postgis.datistemplate = false, I'll be able to drop it, but I don't know how to set that.


Solution

  • postgres=# UPDATE pg_database SET datistemplate='false' WHERE datname='template_postgis';
    UPDATE 1
    postgres=# DROP DATABASE template_postgis;
    DROP DATABASE
    postgres=#