X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E35D2D1B3B2 for ; Wed, 21 Jul 2004 12:29:35 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99172-06 for ; Wed, 21 Jul 2004 15:29:08 +0000 (GMT) Received: from korma.gbdirect.co.uk (userem105.dsl.pipex.com [62.188.200.105]) by svr1.postgresql.org (Postfix) with ESMTP id 16DBBD1B3BB for ; Wed, 21 Jul 2004 12:28:19 -0300 (ADT) Received: from tiger.gbdirect.co.uk (tiger.gbdirect.co.uk [192.168.0.159]) by korma.gbdirect.co.uk (8.12.3/8.11.6) with ESMTP id i6LFSI0k016246; Wed, 21 Jul 2004 16:28:18 +0100 Received: from geoffr by tiger.gbdirect.co.uk with local (Exim 3.35 #1 (Debian)) id 1BnJ11-0005RV-00; Wed, 21 Jul 2004 16:28:19 +0100 Date: Wed, 21 Jul 2004 16:28:19 +0100 From: Geoff Richards To: Michael Kleiser Cc: pgsql-sql@postgresql.org Subject: Re: MySQL-style "create temporary table foo select ..." Message-ID: <20040721152818.GB23820@gbdirect.co.uk> References: <20040721144949.GA23820@gbdirect.co.uk> <40FE86C2.8080903@webde-ag.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40FE86C2.8080903@webde-ag.de> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/159 X-Sequence-Number: 18411 On Wed, Jul 21, 2004 at 05:07:46PM +0200, Michael Kleiser wrote: > create temporary table tmp_foo AS select * from foo; Ah, that's a relief, thanks. Just what I need. Must have missed it in the create table syntax. > 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 > > > -- Geoff Richards - GBdirect - http://development.gbdirect.co.uk/ tel: 0870 200 7273 sales: 0800 651 0338