Re: How to creat tables using record ID in for loop

From: Ragnar <gnari(at)hive(dot)is>
To: CHUNRIMACHUNRIMA <chunrima(at)hotmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to creat tables using record ID in for loop
Date: 2008-08-06 22:35:49
Message-ID: 1218062149.10575.12.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On mið, 2008-08-06 at 18:52 +0000, CHUNRIMACHUNRIMA wrote:
> "96784002";"mylocation #1"
> "02385067";"mylocation #2"
> "01734056";"mylocation #3"
...
> 3. What I want to do is to create tables with staid from mytest table
> using for loop.
...
> +++Example+++
>
> CREATE TABLE s06784000 (
> staid varchar(50),
> val real, -- streamflow
> date date
> )
>
> WITHOUT OIDS;

what about a query that generates texts like
'CREATE TABLE s06784000 .....;'
for each row of your table? then you can either
feed the output to psql, or just EXECUTE them
in a PL/pgSQL function.

>
> 4. I must create tables using for loop because I have millions of
> records.

you want to create millions of tables? you should do a bit of
performance testing before you commit to this, as I
imagine that you might get into scalability problems.

gnari

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Craig Ringer 2008-08-07 02:05:47 Re: more than 1000 connections
Previous Message Alvaro Herrera 2008-08-06 22:18:49 Re: Single Quote in tsquery