Re: CREATE TABLE with a name derived from a string

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Savage <JSavage(at)data-mate(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: CREATE TABLE with a name derived from a string
Date: 2003-02-14 18:36:18
Message-ID: 20030214103333.Q64558-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12 Feb 2003, Savage wrote:

> I am creating a DB for a multi user IM system. Each user can store
> their history. Each user also has a unique ID. There will be many
> users and a lot of history will be generated by each user, so we are
> going to create a history table per user, with a tablename that is
> derived from the unique userid. I've hit a problem implementing this
> scheme.
>
> I want to be able to write a stored procedure in postgres that takes
> an integer userid as a param and creates a table called
> History.<userid>. (e.g. History.695). My dream is:
>
> CREATE TABLE 'History' || $1 (...);

I think using execute might work:

EXECUTE ''CREATE TABLE History'' || $1 || '' (...);'';

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arguile 2003-02-14 18:46:58 Re: natural sort order
Previous Message Lincoln Yeoh 2003-02-14 17:56:26 Re: uppercase = lowercase