create db from a template - Mailing list pgsql-admin

From Marc Fromm
Subject create db from a template
Date
Msg-id 81FEAB8CDDC62B42B6E8AA258228BC8804E925FF@EVS2.univ.dir.wwu.edu
Whole thread Raw
Responses Re: create db from a template  (Shane Ambler <pgsql@Sheeky.Biz>)
List pgsql-admin
Is there a better way to create a database from the schema of another
database, to have a copy of a database without the data?

1.) I get the schema from a database
pg_dump -s -U postgres -O databasename > /tmp/template_name

2.) I create a new database.
createdb -U postgres newdb

3.) I restore the schema to the newdb.
psql -U postgres newdb < /tmp/template_name

4.) I create a database, using the newdb as a TEMPLATE
CREATE DATABASE databasename2 TEMPLATE newdb;


Marc


pgsql-admin by date:

Previous
From: Vishal Arora
Date:
Subject: Re: Postgres Performance
Next
From: "Marc Fromm"
Date:
Subject: exceeds max_fsm_pages