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 EC3F8D1B18A for ; Wed, 21 Jul 2004 12:08:20 -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 88906-07 for ; Wed, 21 Jul 2004 15:07:58 +0000 (GMT) Received: from mailgate3.cinetic.de (mailgate3.cinetic.de [217.72.192.164]) by svr1.postgresql.org (Postfix) with ESMTP id 85AC3D1B3B2 for ; Wed, 21 Jul 2004 12:07:54 -0300 (ADT) Received: from exchange02.int.cinetic.de (exchange02.int.cinetic.de [10.2.1.12]) by mailgate3.cinetic.de (8.11.6p2/8.11.2/SuSE Linux 8.11.0-0.4) with ESMTP id i6LF7kK16610; Wed, 21 Jul 2004 17:07:46 +0200 Received: from webde-ag.de ([10.1.8.177]) by exchange02.int.cinetic.de with Microsoft SMTPSVC(6.0.3790.0); Wed, 21 Jul 2004 17:07:46 +0200 Message-ID: <40FE86C2.8080903@webde-ag.de> Date: Wed, 21 Jul 2004 17:07:46 +0200 From: Michael Kleiser Reply-To: mkl@webde-ag.de Organization: WEB.DE AG User-Agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.3.1) Gecko/20030425 X-Accept-Language: de, de-at, en, en-us MIME-Version: 1.0 To: Geoff Richards Cc: pgsql-sql@postgresql.org Subject: Re: MySQL-style "create temporary table foo select ..." References: <20040721144949.GA23820@gbdirect.co.uk> In-Reply-To: <20040721144949.GA23820@gbdirect.co.uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 21 Jul 2004 15:07:46.0293 (UTC) FILETIME=[7AD44250:01C46F34] 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/156 X-Sequence-Number: 18408 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 >