Re: Create Table Dinamic - Mailing list pgsql-general

From Sam Mason
Subject Re: Create Table Dinamic
Date
Msg-id 20080808140941.GF2193@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to Re: Create Table Dinamic  ("Anderson dos Santos Donda" <andersondonda@gmail.com>)
List pgsql-general
On Thu, Aug 07, 2008 at 10:55:06AM -0300, Anderson dos Santos Donda wrote:
> Each client has a db, and each db has the same tables. I don't need to share
> datas with the clients ( and I can't do it ) , because each clients have
> differents datas in yours tables.
>
> My function is to help me to create a new db with the tables.

You may want to look into the "template" parameter of CREATE DATABASE.
Whenever a database is created it's actually just copied from an
existing database.  It normally comes from "template1", which is a
basically empty and clean database that it's initialized when the
cluster is created (installed).  If you have lots of databases that are
basically the same and unchanging, you may want to create the tables in
one database (say "clienttemplate") and do:

  CREATE DATABASE client101 TEMPLATE 'clienttemplate';

and all the tables/views/stored procedures/other definitions in
the template will be automatically copied into the new database.
One caveat, is that this is a once only operation.  Once the new
database has been created, the link back to the template is lost so
any subsequent changes in the template won't also happen in the new
database.  For more details have a look at [1].


  Sam

 [1] http://www.postgresql.org/docs/current/static/sql-createdatabase.html

pgsql-general by date:

Previous
From: Robert Shaw
Date:
Subject: Re: Vacuum Vs Vacuum Full
Next
From: Magnus Hagander
Date:
Subject: Re: Need info on installer