Subject Re: create table as select
Author Adam
--- In, "kapsee" <kapil.surlaker@...>
> It seems there is no support for creating a table as duplicate of
> another by doing "create table foo as select * from bar".

This does not surprise me, you are mising DDL with DML. You shouldn't
even do that in the same transaction, let alone the same operation.

> The only way seems to be do a create table foo followed by
> insert into bar select * from foo;
> But this requires I specify all the table columns during the create
> Is there a workaround for duplicating a table without specifying all
> the columns of the original table explicitly ?

Not the sort of thing that really makes sense at runtime, but start
with a query to retrieve the data from your bar table

and use the returned values to build your create table statement.

You can use the following syntax once your table exists.

insert into foo select * from bar