Re: How to creat tables using record ID in for loop - Mailing list pgsql-sql

From Ragnar
Subject Re: How to creat tables using record ID in for loop
Date
Msg-id 1218062149.10575.12.camel@localhost.localdomain
Whole thread Raw
In response to How to creat tables using record ID in for loop  (CHUNRIMACHUNRIMA <chunrima@hotmail.com>)
List 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




pgsql-sql by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Single Quote in tsquery
Next
From: Craig Ringer
Date:
Subject: Re: more than 1000 connections