Thread: select into vs. create as

select into vs. create as

From
Oskar Stolc
Date:
Hi.

Is there some difference between creating a new table with

SELECT * INTO newtable FROM oldtable;

and with

CREATE newtable as SELECT * FROM oldtable

?

Are these two commands equivalent ?

Thank you.

Oskar

PS.: Sorry for may english, I am not a native english speeker

Re: select into vs. create as

From
Tom Lane
Date:
Oskar Stolc <stolc@intrak.sk> writes:
> Are these two commands equivalent ?

Yes.

I recommend CREATE AS, though.  plpgsql thinks that SELECT INTO
means something quite different, so you'll inevitably get confused
later on if you use SELECT INTO :-(

            regards, tom lane