Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Drop A Template Database From PostgreSQL

postgres=# DROP DATABASE tempdb;
ERROR: cannot drop a template database
METHOD 1:

  • if we want to drop any database means you need to set datistemplate=false
  • if you want to connect to template0 you need to set dataallowcomm=true

temp0=# UPDATE pg_database SET datistemplate='false' WHERE datname='temp0';
UPDATE 1
--Becouse you cannot drop from connected database temp0 if you want to drop the database you need to connect as another database and drop the temp0 database 
temp0=# DROP DATABASE temp0;                                               
ERROR: cannot drop the currently open database

postgres=# DROP DATABASE tempdb;
DROP DATABASE
METHOD 2:
postgres=# create database temp11 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

Comments

Popular posts from this blog

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

PostgreSQL pgBadger

PostgreSQL Pgbadger Installation On Linux

How to configure Replication Manager (repmgr) ?

How To Schedule PostgreSQL Jobs using pgAgent on Linux plateform