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

Free VPS Host

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

PostgreSQL Database startup / shutdown /restart

ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated ORA-01262: Stat failed on a file destination directory Linux-x86_64 Error: 2: No such file or directory

PostgreSQL pgBadger