Re: Create Table Dinamic - Mailing list pgsql-general

From Igor Neyman
Subject Re: Create Table Dinamic
Date
Msg-id F4C27E77F7A33E4CA98C19A9DC6722A20348B027@EXCHANGE.corp.perceptron.com
Whole thread Raw
In response to Create Table Dinamic  ("Anderson dos Santos Donda" <andersondonda@gmail.com>)
List pgsql-general
Read about dynamic sql in Postgres documentation (EXECUTE statement):

http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html

Igor

-----Original Message-----
From: Anderson dos Santos Donda [mailto:andersondonda@gmail.com]
Sent: Wednesday, August 06, 2008 9:10 PM
To: pgsql-general@postgresql.org
Subject: Create Table Dinamic

Hello All!

Its my first time here in maillist and I started work with postgre on
last moth.

My questions is: Threre is a way to create tables dinamic?

Example:

To create a table we use CREATE TABLE TableName ......

In my db, I have many tables with diferents names but with same colums

Example:

TableOne ( id int, name text );
TableTwo ( id int, name text );
TableThree ( id int, name text );

So, I created a function to create me this tables with diferents names

CREATE OR REPLACE FUNCTION MakeTables ( NameTable text ) RETURNS VOID $$
BEGIN
  CREATE TABLE NameTable ( id int, name text ); END; $$ LANGUAGE
'plpgsql';

But, the plpgsql or postgre don't accept this..

So, How can I create a table with my function?

Thanks for any helps!!!

PS : If somebody want knows why I need to create this function, is
because in my db have 1000 tables with the some colums, and each time I
have a new client, I need to create this tables manually.


pgsql-general by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: bytea encode performance issues
Next
From: "Merlin Moncure"
Date:
Subject: Re: bytea encode performance issues