Re: BUG #2100: CREATE TABLE AS - may not supply table specification

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robert Bengtsson" <robert(at)fbt(dot)se>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2100: CREATE TABLE AS - may not supply table specification
Date: 2005-12-09 16:28:22
Message-ID: 13723.1134145702@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Robert Bengtsson" <robert(at)fbt(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-12-09 16:31:36 Re: BUG #2104: pg_xlog/ trace files not reclaimed by server
Previous Message Reuben Pasquini 2005-12-09 13:43:37 BUG #2104: pg_xlog/ trace files not reclaimed by server