Re: BUG #2100: CREATE TABLE AS - may not supply table specification - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #2100: CREATE TABLE AS - may not supply table specification
Date
Msg-id 13723.1134145702@sss.pgh.pa.us
Whole thread Raw
In response to BUG #2100: CREATE TABLE AS - may not supply table specification  ("Robert Bengtsson" <robert@fbt.se>)
List pgsql-bugs
"Robert Bengtsson" <robert@fbt.se> writes:
> while the following generates an error:

> CREATE TABLE l_modeltext
> (
>   id serial NOT NULL,
>   text varchar(60),
>   make varchar(30),
>   model varchar(30),
>   make_id int4,
>   model_id int4
> ) WITHOUT OIDS AS (SELECT distinct modeltext as text, make, model, make_id,
> model_id from l_modelcode);

That is not the syntax for CREATE TABLE AS, and I don't see anything in
the reference page for CREATE TABLE AS that would suggest that it is.

I'd suggest creating the table with the columns you want and then doing
INSERT ... SELECT to fill it.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Brent Reid"
Date:
Subject: BUG #2102: Backend reports wrong number of affected rows for a table that uses rules
Next
From: Tom Lane
Date:
Subject: Re: BUG #2104: pg_xlog/ trace files not reclaimed by server