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 DA283D1B17B for ; Wed, 21 Jul 2004 11:50:11 -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 79660-01 for ; Wed, 21 Jul 2004 14:49:53 +0000 (GMT) Received: from korma.gbdirect.co.uk (userem105.dsl.pipex.com [62.188.200.105]) by svr1.postgresql.org (Postfix) with ESMTP id B5290D1B38B for ; Wed, 21 Jul 2004 11:49:45 -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 i6LEnn0k015885 for ; Wed, 21 Jul 2004 15:49:49 +0100 Received: from geoffr by tiger.gbdirect.co.uk with local (Exim 3.35 #1 (Debian)) id 1BnIPm-0004SL-00 for ; Wed, 21 Jul 2004 15:49:50 +0100 Date: Wed, 21 Jul 2004 15:49:50 +0100 From: Geoff Richards To: pgsql-sql@postgresql.org Subject: MySQL-style "create temporary table foo select ..." Message-ID: <20040721144949.GA23820@gbdirect.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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/154 X-Sequence-Number: 18406 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