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 find the server is whether standby (slave) or primary(master) in Postgresql replication ?

7 Steps to configure BDR replication in postgresql

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

Ora2PG - Oracle/MySQL to Postgres DB migration Version 20.0

PostgreSQL Introduction