other

Delete postgresql database if it is template

Postgresql can't allow to drop database if it is template. We need to change is_template attribute to false to drop it.

postgres=# create database tempDB is_template true;
CREATE DATABASE
postgres=# drop database tempDB;
ERROR:  cannot drop a template database
postgres=# alter database tempDB is_template false;
ALTER DATABASE
postgres=# drop database tempDB;
DROP DATABASE
postgres=#
Was this helpful?