From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | garry saddington <garry(at)schoolteachers(dot)co(dot)uk> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: create table as problem |
Date: | 2006-09-15 21:00:47 |
Message-ID: | 20060915210047.GA33331@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Sep 15, 2006 at 09:42:35PM +0100, garry saddington wrote:
> I am getting a syntax error at or near 'as' in this method, can anyone
> help?
>
> create table iclasses
> (classid serial,
> subject text,
> year text,
> groups text,
> teacher text,
> set text
> )
> as select distinct subject,year,groups,teacher,set from interimclasses
With CREATE TABLE AS you can specify column names but not column
types. If you want to create more columns than the query returns
then try an ordinary CREATE TABLE followed by INSERT INTO ... SELECT.
CREATE TABLE iclasses (
classid serial,
subject text,
year text,
groups text,
teacher text,
set text
);
INSERT INTO iclasses (subject, year, groups, teacher, set)
SELECT DISTINCT subject, year, groups, teacher, set
FROM interimclasses;
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | Angva | 2006-09-15 22:17:38 | create index in parallel? |
Previous Message | garry saddington | 2006-09-15 20:42:35 | create table as problem |