Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 345222E0047 for ; Thu, 20 Mar 2008 21:46:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 31812-02 for ; Thu, 20 Mar 2008 21:45:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from ipmail01.adl6.internode.on.net (ipmail01.adl6.internode.on.net [203.16.214.146]) by postgresql.org (Postfix) with ESMTP id 5661A2E004A for ; Thu, 20 Mar 2008 21:45:52 -0300 (ADT) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As4EAM+f4kfLevdH/2dsb2JhbACBWqk1 X-IronPort-AV: E=Sophos;i="4.25,534,1199626200"; d="scan'208";a="66331424" Received: from ppp247-71.static.internode.on.net (HELO DevBox.local) ([203.122.247.71]) by ipmail01.adl6.internode.on.net with ESMTP; 21 Mar 2008 11:15:42 +1030 Message-ID: <47E30534.20702@Sheeky.Biz> Date: Fri, 21 Mar 2008 11:15:40 +1030 From: Shane Ambler User-Agent: Thunderbird 2.0.0.12 (Macintosh/20080213) MIME-Version: 1.0 To: Marc Fromm CC: pgsql-admin@postgresql.org Subject: Re: create db from a template References: <81FEAB8CDDC62B42B6E8AA258228BC8804E925FF@EVS2.univ.dir.wwu.edu> In-Reply-To: <81FEAB8CDDC62B42B6E8AA258228BC8804E925FF@EVS2.univ.dir.wwu.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/182 X-Sequence-Number: 28665 Marc Fromm wrote: > 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 > > You only need those 4 steps once to start with then each new one will just use step 4. So you can either setup the database as you have done and use it as the template for all the similar db's you want which means each new one will only need step 4. The other way is do 4 without using the TEMPLATE and then adjust 3 to import the schema dump into the db just created (databasename2 in this case) -- Shane Ambler pgSQL (at) Sheeky (dot) Biz Get Sheeky @ http://Sheeky.Biz