Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group