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

PostgreSQL pgBadger

PostgreSQL Pgbadger Installation On Linux

How to configure Replication Manager (repmgr) ?

What's is the difference between streaming replication Vs hot standby vs warm standby ?

Script to kill ALL IDLE Connection In postgreSQL