How does one drop a template database from PostgreSQL?

后端 未结 3 435
小鲜肉
小鲜肉 2021-01-30 12:33
postgres=# DROP DATABASE template_postgis;
ERROR:  cannot drop a template database

http://www.postgresql.org/docs/9.1/static/manage-ag-templatedbs.html

3条回答
  •  青春惊慌失措
    2021-01-30 13:19

    You can use the alter database command. Much simpler and safer than upsetting metadata.

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

    Documentation

提交回复
热议问题