pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
MySQL-style "create temporary table foo select ..."
3+ messages / 2 participants
[nested] [flat]

* MySQL-style "create temporary table foo select ..."
@ 2004-07-21 14:49  Geoff Richards <geoffr@gbdirect.co.uk>
  0 siblings, 1 reply; 3+ messages in thread

From: Geoff Richards @ 2004-07-21 14:49 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: MySQL-style "create temporary table foo select ..."
@ 2004-07-21 15:07  Michael Kleiser <mkl@webde-ag.de>
  parent: Geoff Richards <geoffr@gbdirect.co.uk>
  0 siblings, 1 reply; 3+ messages in thread

From: Michael Kleiser @ 2004-07-21 15:07 UTC (permalink / raw)
  To: Geoff Richards <geoffr@gbdirect.co.uk>; +Cc: 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
> 




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: MySQL-style "create temporary table foo select ..."
@ 2004-07-21 15:28  Geoff Richards <geoffr@gbdirect.co.uk>
  parent: Michael Kleiser <mkl@webde-ag.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Geoff Richards @ 2004-07-21 15:28 UTC (permalink / raw)
  To: Michael Kleiser <mkl@webde-ag.de>; +Cc: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-07-21 15:28 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-21 14:49 MySQL-style "create temporary table foo select ..." Geoff Richards <geoffr@gbdirect.co.uk>
2004-07-21 15:07 ` Michael Kleiser <mkl@webde-ag.de>
2004-07-21 15:28   ` Geoff Richards <geoffr@gbdirect.co.uk>

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