Re: Create Table Dinamic

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Create Table Dinamic
Date: 2008-08-08 14:09:41
Message-ID: 20080808140941.GF2193@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2008-08-08 14:31:02 Re: Need info on installer
Previous Message Tom Lane 2008-08-08 13:28:10 Re: Initdb problem on debian mips cobalt: Bus error