¿Cómo se elimina una base de datos de plantillas de PostgreSQL?


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

Http://www.postgresql.org/docs/9.1/static/manage-ag-templatedbs.html hace que parezca que si establezco template_postgis.datistemplate = false, podré soltarlo, pero no se cómo configurarlo.

Author: dbkaplun, 2012-07-09

2 answers

postgres=# UPDATE pg_database SET datistemplate='false' WHERE datname='template_postgis';
UPDATE 1
postgres=# DROP DATABASE template_postgis;
DROP DATABASE
postgres=# 
 73
Author: dbkaplun,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-07-09 03:33:39

Puede usar el comando alter database. Mucho más simple y seguro que alterar los metadatos.

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=# 

Documentación

 8
Author: Mokadillion,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-04 08:44:32