Re: create view bug

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jefim Matskin <mjefim(at)sphera(dot)com>
Cc: "'pgsql-bugs(at)PostgreSQL(dot)org'" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: create view bug
Date: 2001-07-23 15:00:02
Message-ID: 15193.995900402@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Jefim Matskin <mjefim(at)sphera(dot)com> writes:
> The follwoing statement does not work:
> create view testview (primary) as select 'true';
> The error I get is:
> ERROR: parser: parse error at or near "primary"

This is not a bug --- the syntax of CREATE VIEW has no provision for a
column name list after the view name. You can control the view column
names like this:

play=> create view testview as select 'true'::bool as primary;
CREATE 4581172 1
play=> \d testview
View "testview"
Attribute | Type | Modifier
-----------+---------+----------
primary | boolean |
View definition: SELECT 't'::bool AS "primary";

play=>

Note also the cast to ensure the column has a well-defined data type...

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2001-07-23 15:18:39 Re: create view bug
Previous Message Tom Lane 2001-07-23 14:25:24 Re: date style bug