| This page is user contributed documentation. See the bottom of the page for information about the author. | |
chocolate-mousse:> psql -U postgres template1
Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
template1=# DROP DATABASE staffos;
DROP
template1=# CREATE DATABASE staffos;
CREATE
template1=# \i staffos_revised.pgdump
CREATE
CREATE
CREATE
CREATE
etc ...
template1=# \c template0
FATAL 1: Database "template0" is not currently accepting connections
Previous connection kept
template1=# select * from pg_database;
datname | datdba | encoding | datistemplate | datallowconn |
-------------+--------+----------+---------------+--------------+
backup_test | 27 | 0 | f | t |
britlist | 27 | 0 | f | t |
dcl | 1 | 0 | f | t |
template0 | 1 | 0 | t | f |
kevinprob | 28 | 0 | f | t |
kitchen | 1 | 0 | f | t |
oooconlist | 103 | 0 | f | t |
regression | 1 | 0 | f | t |
staffos | 27 | 0 | f | t |
template1 | 1 | 0 | t | t |
etc ...
template1=# UPDATE pg_database SET datallowconn = TRUE
template1-# WHERE datname = 'template0';
UPDATE 1
template1=# \c template0
CONNECT
template0=# drop database template1;
ERROR: DROP DATABASE: database is marked as a template
template0=# UPDATE pg_database SET datistemplate = FALSE
template0-# WHERE datname = 'template1';
UPDATE 1
template0=# drop database template1;
DROP
template0=# create database template1 with template = template0;
CREATE
template0=# UPDATE pg_database SET datistemplate = TRUE
template0-# WHERE datname = 'template1';
UPDATE 1
template0=# \c template1
CONNECT
template1=# UPDATE pg_database SET datallowconn = FALSE
template1-# WHERE datname = 'template0';
template1-# VACUUM FULL FREEZE;
VACUUM