Re: CREATE TABLE with a name derived from a string - Mailing list pgsql-general

From Stephan Szabo
Subject Re: CREATE TABLE with a name derived from a string
Date
Msg-id 20030214103333.Q64558-100000@megazone23.bigpanda.com
Whole thread Raw
In response to CREATE TABLE with a name derived from a string  (JSavage@data-mate.com (Savage))
Responses Re: CREATE TABLE with a name derived from a string
List 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 || '' (...);'';


pgsql-general by date:

Previous
From: Francisco J Reyes
Date:
Subject: Re: Measuring Performance/Tuning
Next
From: Arguile
Date:
Subject: Re: natural sort order