pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Kleiser <mkl@webde-ag.de>
To: Geoff Richards <geoffr@gbdirect.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: MySQL-style "create temporary table foo select ..."
Date: Wed, 21 Jul 2004 17:07:46 +0200
Message-ID: <40FE86C2.8080903@webde-ag.de> (raw)
In-Reply-To: <20040721144949.GA23820@gbdirect.co.uk>
References: <20040721144949.GA23820@gbdirect.co.uk>

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
> 




view thread (3+ messages)  latest in thread

Message-ID: <40FE86C2.8080903@webde-ag.de>
Permalink:  ../40FE86C2.8080903@webde-ag.de/
Also on:    postgresql.org/message-id/40FE86C2.8080903@webde-ag.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mkl@webde-ag.de, geoffr@gbdirect.co.uk
  Subject: Re: MySQL-style "create temporary table foo select ..."
  In-Reply-To: <40FE86C2.8080903@webde-ag.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox