MySQL-style "create temporary table foo select ..."

From: Geoff Richards <geoffr(at)gbdirect(dot)co(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: MySQL-style "create temporary table foo select ..."
Date: 2004-07-21 14:49:50
Message-ID: 20040721144949.GA23820@gbdirect.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I've got some code that currently uses MySQL, and it copies an existing
table into a temporary one like so:

create temporary table tmp_foo select * from foo;

That creates 'tmp_foo' with the same columns as 'foo', which is
very convenient. I can't seem to find any reference to how to do
that with Postgres (and I'd like if possible to ditch MySQL).

Just wondering if anyone has ideas about how to do this? I'd like
to avoid having to work up a table definition to define the temp
table's columns.

Or maybe I could do some sort of trick with the system catalog tables
to get the column information in a convenient form?

cheers,
geoff

--
Geoff Richards - GBdirect - http://development.gbdirect.co.uk/
tel: 0870 200 7273 sales: 0800 651 0338

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2004-07-21 14:51:20 Re: immutable function calling stable function
Previous Message Tom Lane 2004-07-21 14:45:34 Re: immutable function calling stable function