Skip site navigation (1) Skip section navigation (2)

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

From: Michael Kleiser <mkl(at)webde-ag(dot)de>
To: Geoff Richards <geoffr(at)gbdirect(dot)co(dot)uk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: MySQL-style "create temporary table foo select ..."
Date: 2004-07-21 15:07:46
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
create temporary table tmp_foo AS select * from foo;

Geoff Richards schrieb:
> 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

In response to


pgsql-sql by date

Next:From: Javier Tesis Tolosa TrabajoDate: 2004-07-21 15:08:46
Subject: Sorry too many conecctions
Previous:From: Stephan SzaboDate: 2004-07-21 14:51:20
Subject: Re: immutable function calling stable function

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group