create db from a template

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux