Re: create view bug - Mailing list pgsql-bugs

From Tom Lane
Subject Re: create view bug
Date
Msg-id 15193.995900402@sss.pgh.pa.us
Whole thread Raw
In response to create view bug  (Jefim Matskin <mjefim@sphera.com>)
List pgsql-bugs
Jefim Matskin <mjefim@sphera.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

pgsql-bugs by date:

Previous
From: Jefim Matskin
Date:
Subject: create view bug
Next
From: Tom Lane
Date:
Subject: Re: date style bug